Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] recursive tree log grep ?


On Sat, 21 May 2005 11:20 pm, James Gray wrote:
> On Sat, 21 May 2005 11:12 pm, Voytek Eymont wrote:
> > I have tree like:
> >
> > /home/domain.tld/logs/
> > /home/domain2.tld/logs/
> > ...
> >
> > how do i run a grep across all logs, as in 'grep a-string /home/*/logs/*'
>
> man grep
>
> -R, -r, --recursive
>         Read all files under each directory, recursively; this is
> equivalent to the -d recurse option.
>
> Makes sense when you think that a lot of Gnu tools use either -r or -R for
> recursive modifiers :) eg,
>
> for DIR in `ls -d /home/*`
> do
> grep -R a-string $DIR
> done

Oops.  That script should read:

for DIR in `ls -d /home/*`
do
grep -R a-string $DIR/logs/
done

James
-- 
The chicken that clucks the loudest is the one most likely to show up
at the steam fitters' picnic.