recursive grep

J. Eric Townsend erict at flatline.UUCP
Sun Sep 3 07:24:25 AEST 1989



About a year ago, I wanted to be able to traverse the entire
/usr/spool/news tree and search for keywords in articles.  (Hey,
I was bored. :-)

It's a kludge, it's not pretty, and it probably uses more than it's
share of system time.  If you can suggest a way to make
it cleaner/faster, please let me know.  Flames>/dev/null.

However, it's basic /bin/sh, and I've yet to find a place that it
*doesn't* work.

#!/bin/sh
#^^^^^^^^ Wish I had csh to see if this really works. :-)
#try -- recursive search directory structure
#usage: try directory string
#LIVES= it's home directory
LIVES=/u/erict/bin
for i in $1/*
do
if test -d $i
then
   $LIVES/try $i $2 2>/dev/null
#error into devnull handles the "can't open foo" error messages! :-P
else
   grep "$2" $i
fi
done
-- 
"Watch has a clock on it" -- ficc!peter's 3.7 year old son, on seeing
                              an analog watch.
J. Eric Townsend unet!sugar!flatline!erict com6 at uhnix1.uh.edu
EastEnders Mailing list: eastender at flatline.UUCP



More information about the Comp.unix.wizards mailing list