Path: utzoo!attcan!uunet!ogicse!husc6!encore!mperlman From: mperlman@Encore.COM (Mark Perlman) Newsgroups: comp.unix.questions Subject: Re: grep Message-ID: <13035@encore.Encore.COM> Date: 23 Oct 90 22:29:50 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> <2822@lectroid.sw.stratus.com> Reply-To: mperlman@encore.Com (Mark Perlman) Organization: Independent Consultant Lines: 31 >>In article <1990Oct23.123025.18012@kodak.kodak.com> tiefel@sunshine.Kodak.COM (Lenny Tiefel) writes: >> >> >> I have a main directory with hundreds of subdirectories, >> and I want to find a file with a particular string, say "xyz" >> The grep command only works in one directory at a time. Is there >> a way of searching my whole directory structure to find a file >> with a particular string? >> >> Thanks. Here's a little script I use to search for strings. ====================================================== #!/bin/csh -f foreach i ( `find . -type d -print` ) (cd $i;echo "<`pwd`>";grep $1 *[hc]) end ====================================================== I created it specifically because I new I had subdirs and I wasn't sure where the string was that I was looking for. This script assumed I was looking at source code, hence, "grep $1 *[hc]" ^^^^^ You might also want to change the arglist ( $1 ) to ( $* ) to capture any flags you may wish to invoke with grep. -- Mark R. Perlman Independent Consultant 301-206-2016 14014 Oakpointe Dr. mperlman@encore.com Laurel, MD 20707 uunet!gould!mperlman