grep
Mark Perlman
mperlman at Encore.COM
Wed Oct 24 08:29:50 AEST 1990
>>In article <1990Oct23.123025.18012 at kodak.kodak.com> tiefel at 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 at encore.com
Laurel, MD 20707 uunet!gould!mperlman
More information about the Comp.unix.questions
mailing list