[vox-tech] Bash scripting newbie - need syntax help

Bill Kendrick vox-tech@lists.lugod.org
Wed, 28 Apr 2004 11:31:53 -0700


On Wed, Apr 28, 2004 at 11:14:14AM -0700, Dave Margolis wrote:
> 
> i agree, find is recursive by nature.  no need to account for recursion 
> with a script.  question:  how does piping ot xargs differ from using 
> the -exec switch of find?

Say you had files "deleteme", "metoo" and "imouttahere"

  find . -type f -exec rm {} \;

would cause this to happen:

  rm deleteme
  rm metoo
  rm imouttahere

whereas the xargs method:

  find . -type f | xargs rm

would cause this:

  rm deleteme metoo imouttahere


A bit quicker; less process forking, yada-yada-yada.


Now, why do that instead of just typing that "rm" by hand (or using
wildcards)?  Well, see the first post in this thread! :^)
(i.e., bash complaining about too many arguments)


Mike Simons taught me this one.  But then again, he taught me about 50% of
what I know. ;)

-bill!