On Sat, Mar 27, 2021 at 5:50 PM Weatherby,Gerard <gweathe...@uchc.edu>
wrote:

> find. -name 0 -exec rm -fr {} \;


-exec rm is very likely a better choice in a lot of ways than xargs here,
but using -exec .... {} \; introduces a lot of overhead because it only
processes one file at a time.     This would be substantially more
efficient:

find. -name 0 -exec rm -fr -- {} \+



The "--" is probably superfluous in this case but it is generally good
practice.  It's there in case the rm command likes (like GNU rm) to
recognize options which come after arguments.   This is an example of this
in action:

$ rm -fr */0/1.txt -i
rm: remove regular empty file 'x/0/1.txt'? n
rm: remove regular empty file 'y/0/1.txt'? n
rm: remove regular empty file 'z/0/1.txt'? n

 Personally, I would probably use -delete to avoid the overhead of -exec
entirely (the explicit -depth is essentially only there for documentation):

find . -depth \( -path '*0/*' -o -path '*0' \) -delete

James.

Reply via email to