So on the basis of Joachim's last diff, i'm trying to put everything together to get it off the table:
* I do think that -or in the last example makes sense. That example is not just about precedence in general, but it also makes the point that explicit final -print is different from implicit final -print: the former needs explicit parentheses, which the latter doesn't. * find -print is not only dangerous with rm, but with practically all other programs, in particular the shell. Perhaps this even shorter wording is clearer: "Passing output of find to other programs requires some care." * Display the example file names in CAVEATS as suggested by Jason. Index: find.1 =================================================================== RCS file: /cvs/src/usr.bin/find/find.1,v retrieving revision 1.78 diff -u -p -r1.78 find.1 --- find.1 15 Jul 2010 20:51:38 -0000 1.78 +++ find.1 14 Sep 2010 23:00:42 -0000 @@ -126,13 +126,9 @@ quotes, backslash space, tab, and newline .Pq Sq \en characters. -Alternatively, the +Consider using .Fl print0 -primary may be used in conjunction with the -.Fl 0 -option to -.Xr xargs 1 , -allowing all file names to be processed safely. +instead. .It Fl x Prevents .Nm @@ -386,7 +382,10 @@ character. .It Ic -print0 This primary always evaluates to true. It prints the pathname of the current file to standard output, followed -by a null character. +by a null character, suitable for use with the +.Fl 0 +option to +.Xr xargs 1 . .It Ic -prune This primary always evaluates to true. It causes @@ -525,11 +524,13 @@ ending in a dot and single digit, but sk .Pp .Dl "$ find /usr/src -path /usr/src/gnu -prune -or -name \e*.[0-9]" .Pp -Find and remove all *.jpg files in the current working directory: +Find and remove all *.jpg and *.gif files under the current working +directory +.Pq see also Sx CAVEATS : .Pp -.Dl "$ find . -name \e*.jpg -exec rm {} \e;" +.Dl "$ find . \e( -name \e*.jpg -or -name \e*.gif \e) -exec rm {} \e; or -.Dl "$ find . -name \e*.jpg | xargs rm" +.Dl "$ find . \e( -name \e*.jpg -or -name \e*.gif \e) -print0 | xargs -0r rm" .Sh SEE ALSO .Xr chflags 1 , .Xr chmod 1 , @@ -637,6 +638,26 @@ In particular, the characters and .Ql \&; may have to be escaped from the shell. +.Pp +Passing output of +.Nm +to other programs requires some care: +.Pp +.Dl "$ find . -name \e*.jpg | xargs rm" +or +.Dl "$ rm `find . -name \e*.jpg`" +.Pp +would, given file names +.Dq important\ .jpg +and +.Dq important , +remove +.Dq important . +Use the +.Ic -print0 +or +.Ic -exec +primaries instead. .Pp As there is no delimiter separating options and file names or file names and the