pipelines with paths containing spaces

Jeremy Bopp jeremy@bopp.net
Sun Aug 30 21:11:00 GMT 2009


David Christensen wrote:
> I am having trouble using pipelines with paths containing spaces:

This is not technically a Cygwin-specific issue, so I'm going to try to
keep this short.

>     2009-08-31 01:16:50 Administrator@p43400e ~
>     $ ls -d /cygdrive/c/Documents\ and\ Settings/ | xargs ls
>     ls: cannot access /cygdrive/c/Documents: No such file or directory
>     ls: cannot access and: No such file or directory
>     ls: cannot access Settings/: No such file or directory

Please refer to the manpage for xargs by running the following:

man xargs

That should explain why the path is being split.

>     2009-08-31 01:16:55 Administrator@p43400e ~
>     $ ls `ls -d /cygdrive/c/Documents\ and\ Settings/`
>     ls: cannot access /cygdrive/c/Documents: No such file or directory
>     ls: cannot access and: No such file or directory
>     ls: cannot access Settings/: No such file or directory

This happens because of the way Bash, the shell you're running, splits
things into words.  See the manpage for bash:

man bash

Look for the IFS variable's description in the Shell Variables section.
 The following section of the Bash manual is also good:

http://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html#Word-Splitting

-Jeremy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list