help with a bash script

Kurt Wall kwall
Mon May 17 12:00:45 PDT 2004


In a 1.3K blaze of typing glory, Brad De Vries wrote:
> --- Kurt Wall <kwall at kurtwerks.com> wrote:
> > 
> > --- cut---
> > #!/bin/sh
> > cd /some/dir
> > find . -type f -mtime +5 | xargs rm
> > --- cut ---
> 
> Is there any reason for not using the -exec parameter
> of the find command:
> 
> find . -type f -mtime +5 -exec rm {} \;

It is inefficient. xargs constructs a command line based on the input
piped to it (up to a built-in limit that you can modify on the command
line), whereas -exec executes the command for each argument.

Kurt
-- 
If you eat a live frog in the morning, nothing worse will happen to
either of you for the rest of the day.



More information about the Linux-users mailing list