17 Oct
2006
17 Oct
'06
9:25 p.m.
On Tue, 17 Oct 2006, Noel Jones wrote:
On 10/17/06, Geert Hendrickx ghen@telenet.be wrote:
On *BSD you can also use find -X which properly quotes the results.
Nope, find -X skips files with strange characters. find -print0 | xargs -0 is the proper solution. $ man find
If you want to use a non-portable construct like "-print0", then there is a better way: use a "find" with built-in "xargs"-style functionality, like the "find" in recent versions of Solaris.
From the manual page:
-exec command
True if the executed command returns a zero value as
exit status. The end of command must be punctuated by
an escaped semicolon (;). A command argument { }
is replaced by the current path name. If the last
argument to -exec is { } and you specify + rather than
the semicolon (;), the command is invoked fewer times,
with { } replaced by groups of pathnames.
So, for example, you can use
find . -type f -name '*whatever*' -exec rm '{}' '+'
This avoids all the quoting issues as the files never even pass through the pipe.
- Logan