find, xargs and spaces
Fri Jul 4 18:43:00 GMT 2008
If file names and directories identified by "find" do not contain spaces
then the command
find . | xargs .. | xargs .. | xargs ..
can be chained almost indefinitely. If there are spaces in the names
find . -print0 | xargs -0 ..
find . -print0 | xargs -0 .. | xargs -0 ..
fails. (As an example I might want to identify all files containing ^L
which do not contain NUL:
find . | xargs grep -PL "\x00" | xargs grep -Pl "\x0c"
works as long as there are no spaces in the pathname but, when there are,
find . -print0 | xargs -0 grep -PL "\x00" | xargs -0 grep -Pl "\x0c"
fails.) (There are probably alternative ways of attacking this specific
problem that avoid the -print0 .. -0 .. but I would be interested in a
I know this is not Cygwin-specific but if there is a simple answer I
would really appreciate the help.
More information about the Cygwin-talk