[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: Filenames with spaces in them



On 28-Aug-98 Tomt wrote:
>       I have some files I've transfered from my Windows NT machine and
> they have several spaces in them like
> This is a Test.txt
> 
> How does linux treat spaces I'm tried the filename listed above and a
> couple of other variants?

If such a name is read from a directory entry (e.g. you do "ls" on the
directory they are in) then they will be read out as they are, spaces
included.

If you need to use the name in a command, then you must shield it from
the shell (which will treat the spaces as separating the name into
distinct arguments "This" "is" "a" "Test.txt").

Depending on what you are doing, putting it in quotes will probably be
sufficient at the top level. The shell will strip the quotes and take
their contents as one item. If you have a shell within a shell then you
have to take extra precautions. One of the best things you can do with
such filenames is to rename them immediately:

   mv "This is a Test.txt" This_is_a_Test.txt

Then your worries are over.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk>
Date: 28-Aug-98                                       Time: 09:51:40
--------------------------------------------------------------------


Reply to: