Hi Otto,

Otto Moerbeek wrote on Wed, Feb 09, 2011 at 09:43:54AM +0100:
> On Wed, Feb 09, 2011 at 12:25:09AM -0700, Clint Pachl wrote:
 
>> In the caveats section it states the following:
>> 
>> 
>>      Passing the output of find to other programs requires some care:
>> 
>>            $ find . -name \*.jpg | xargs rm
>>      or
>>            $ rm `find . -name \*.jpg`
>> 
>>      would, given files ``important .jpg'' and ``important'', remove
>>      ``important''.  Use the -print0 or -exec primaries instead.
>> 
>> 
>> Is this an error? The language indicates that ``important'' will be
>> removed (and possibly ``important.jpg''; it's not clear) when
>> executing both above commands. Is this correct?
>> 
>> If it is correct, then I don't get what the caveat is. For example:
>> 
>> $ touch important important.jpg
>> $ find . -name \*.jpg | xargs rm
>> $ ls
>> important
>> 
>> What does -print0 or -exec have to do with it?

> You should read more carefully. There's a space in one of the filenames.

Sure.

However, since the section is called CAVEATS not RIDDLES,
maybe the following is a further improvement?

When committing that CAVEAT back in September, it didn't occur
to me how easy it is to miss a blank character in an example
when you are not already expecting whitespace to be the issue.
Besides, mentioning that whitespace is not the only issue might
be worthwhile as well.

OK?

Yours,
  Ingo


Index: find.1
===================================================================
RCS file: /cvs/src/usr.bin/find/find.1,v
retrieving revision 1.81
diff -u -r1.81 find.1
--- find.1      29 Sep 2010 07:44:56 -0000      1.81
+++ find.1      9 Feb 2011 23:05:44 -0000
@@ -643,7 +643,8 @@
 .Ql \&;
 may have to be escaped from the shell.
 .Pp
-Passing the output of
+As file names may contain whitespace and shell metacharacters,
+passing the output of
 .Nm
 to other programs requires some care:
 .Pp

Reply via email to