find / -name "*find*" -print0 | grep -v baddir | xargs -0 command
[...]
/me points to grep's -z and -Z option
True, but you get the point. There are many command that could be in
that pipe: sed, sort, etc.
There is also the possibility to plug in tr in between:
find ... -print | do someting | do something ... \
tr '\n' '\0' \
xargs -0 command
Good tip.
I'd strongly advise against this hack (actually any use of xargs
without -n) on untrusted directories as it will break dangerously
with filenames containing newline.
[EMAIL PROTECTED]:/tmp/test$ mkdir 'foo
'
[EMAIL PROTECTED]:/tmp/test$ mkdir 'foo
'/etc
[EMAIL PROTECTED]:/tmp/test$ echo blah > 'foo
/etc'/passwd
[EMAIL PROTECTED]:/tmp/test$ find
.
./foo?
./foo?/etc
./foo?/etc/passwd
[EMAIL PROTECTED]:/tmp/test$ find -type f -print | xargs ls -l
ls: ./foo: No such file or directory
-rw-r--r-- 1 root root 1201 Jan 22 11:16 /etc/passwd
An interesting example. Isn't security wonderful? However, in
non-security related matters, having spaces is quite common while having
newlines is extremely rare.
Brian
( [EMAIL PROTECTED] )
-------------------------------------------------------------------------------
Do, or do not. There is no "try". -- Yoda
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]