> From: "Ted Unangst" <t...@tedunangst.com> > Date: Tue, 03 Jan 2017 16:39:48 -0500 > > I copied this straight from freebsd. Not fixed, but feel free to correct as > desired. > > This adds a third example showing -delete, mentioning that it's not standard, > but also hinting that it may work better than "rm -r" when you want to delete > directories.
I really think we should not encourage unportable code like that by giving an example in our manual page. I'm even tempted to say that you should leave the "-exec rm {} \;" example alone. The + here only works because rm(1) accepts multiple file arguments. And I don't understand the sentence about recursively removing non-empty directories; rm(1) doesn't remove directories unless you use the -r option! > Index: find.1 > =================================================================== > RCS file: /cvs/src/usr.bin/find/find.1,v > retrieving revision 1.92 > diff -u -p -r1.92 find.1 > --- find.1 3 Jan 2017 21:31:16 -0000 1.92 > +++ find.1 3 Jan 2017 21:36:30 -0000 > @@ -575,9 +575,15 @@ ending in a dot and single digit, but sk > Find and remove all *.jpg and *.gif files under the current working > directory: > .Pp > -.Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -exec rm {} \e;" > +.Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -exec rm {} +" > or > .Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -print0 | xargs -0r rm" > +or > +.Dl "$ find . \e( -name \e*.jpg -o -name \e*.gif \e) -delete" > +.Pp > +Note that this third version is not guaranteed to be portable. > +However, if it is desired to delete directories as well, it may be safer > +because it will not accidentally recursively remove non-emtpy directories. > .Sh SEE ALSO > .Xr chflags 1 , > .Xr chmod 1 , > >