system command to copy a file to a path with a space in it
Kenneth Brody
kenbrody at spamcop.net
Wed Mar 25 08:56:24 PDT 2015
On 3/25/2015 11:41 AM, Richard Kreiss wrote:
> Just for a clarification, can a directory name contain a space?
There is no difference between a "directory name" and a "file name". On
*nix systems, there are only two characters which cannot be part of a file
name: '/' and '\0'. (The slash and the nul character.)
It is perfectly legal to have, for example, a backspace character in a
filename. Or even "<ESCape> [ D" (the ANSI "cursor left" sequence). Makes
for "interesting" filenames when, for example, you type
"f00<left-arrow><left-arrow>oobar" as the filename, and a directory listing
appears to show "foobar". (I think "modern" shells interpret the left-arrow
differently than they used to, so I'm not sure if that would happen today.
But I've seen it many times in the past. "How come it tells me 'file not
found'" or "how can I have two files with the same name".)
Trailing spaces are also legal.
For fun (FSVO), create a file named "-rf *" via:
echo >"-rf *"
Now, try removing it.
Make sure you have a backup first, "just in case". :-)
NB: I take no responsibility in what happens if you do it wrong.
> In this example there seems to be a space after /cp /but before Reports.
[...]
>>> system "/bin/cp /reports/state.pdf '/reports/Josh Reader/josh.pdf'"
[...]
That's because "/bin/cp" is the command, and "/reports/state.pdf" is the
first argument. The space separates them. (Just as, without the quotes,
"/reports/Josh" would be the second argument, with "Reader/josh.pdf" being
the third.)
--
Kenneth Brody
More information about the Filepro-list
mailing list