help with a bash script
Brad De Vries
devriesbj
Mon May 17 12:00:46 PDT 2004
--- Marianne Taylor <mataylor at shaw.ca> wrote:
> On March 19, 2004 07:12, Kurt Wall wrote:
> > 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
>
> Thanks Joel and Kurt and anyone else that helped. I
> knew there was an easier
> way than what I had. One question... Is it
> necessary to specify "." for the
> current directory or is that the default behaviour?
>
> Additionally if I run the following line to test
> this
>
> find . -type f -mtime +15 -exec rm {}\;
>
> I get this error message ...
>
> find: missing argument to `-exec'
To answer your question, you do not need to specify
the "." for the current directory. The find command
will use "." if no path is specified but that feature
is not standard across all UNIX systems. Another nice
GNU enhancement is the that you can specify multiple
paths one one command:
/root# find . /tmp -print
This command will print all the files in the current
directory followed by all the files in the /tmp
directory.
Enjoy,
Brad.
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
More information about the Linux-users
mailing list