Spaces in Unix file names

Cornelius Krasel krasel at wpxx02.toxi.uni-wuerzburg.de
Wed Oct 1 15:08:38 EST 1997

> Some older ABI sequencers make files named (e.g.)"Sample 01.Seq" on their
> Macs. Dartmouth's Fetch for some reason will copy the file to Unix and
> leave the space in the filename (It doesn't do that to VMS.).  
> SeqLab chokes on such entries since space is a field delimiter in Unix 
> commands. 
> Does anyone know how to doctor Fetch to always remove blanks?
> Does anyone have a script that'll remove blanks from filenames on a
> Unix System?

First, there is no problem with spaces in filenames on Unix systems.
The only thing that you have to do is to escape the space. For example:

~% touch 'with space'
~% ls -l w*
-rw-r--r--   1 krasel   users           0 Oct  1 21:58 with space
~% ls with\ space
-rw-r--r--   1 krasel   users           0 Oct  1 21:58 with space

shows two possibilities how to use a file with space in the filename.
I have no idea whether that will work with SeqLab, though.

To change filenames with spaces into filenames without spaces, do
something like the following (should work for a bash-like shell):

for i in *\ *
   new=`echo $i|tr -d ' '`
   mv $i $new

This will rename all files "with space" in your current directory in
"withspace". If "withspace" exists, it will be overwritten.

Hope that helps,


/* Cornelius Krasel, U Wuerzburg, Dept. of Pharmacology, Versbacher Str. 9 */
/* D-97078 Wuerzburg, Germany   email: phak004 at rzbox.uni-wuerzburg.de  SP4 */
/* "Science is the game we play with God to find out what His rules are."  */

More information about the Info-gcg mailing list

Send comments to us at biosci-help [At] net.bio.net