Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!texbell!uhnix1!flatline!erict From: erict@flatline.UUCP (J. Eric Townsend) Newsgroups: comp.unix.wizards Subject: Re: recursive grep Summary: My solution Message-ID: <2375@flatline.UUCP> Date: 2 Sep 89 21:24:25 GMT References: <7774@cbmvax.UUCP> <677@lakart.UUCP> Reply-To: erict@flatline.UUCP (J. Eric Townsend) Organization: Cabal of B-Boys Lines: 34 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@uhnix1.uh.edu EastEnders Mailing list: eastender@flatline.UUCP