This is the mail archive of the
cygwin-talk
mailing list for the cygwin project.
find, xargs and spaces
- From: Fergus <fergus at bonhard dot uklinux dot net>
- To: cygwin-talk at cygwin dot com
- Cc: Fergus <fergus at bonhard dot uklinux dot net>
- Date: Fri, 04 Jul 2008 19:41:09 +0100
- Subject: find, xargs and spaces
- Reply-to: The Vulgar and Unprofessional Cygwin-Talk List <cygwin-talk at cygwin dot com>
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 ..
works but
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
general solution.)
I know this is not Cygwin-specific but if there is a simple answer I
would really appreciate the help.
Thank you.
Fergus