grep

Robert Perlberg perl at step.UUCP
Thu Oct 25 23:36: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?

find . ! -type d -print|xargs grep xyz /dev/null

Specifying /dev/null as the first file argument to grep deals with the
case where xargs passes only one argument to grep.  That would cause
grep to not display the name of the file if it found the search string
in the file.  Passing /dev/null to each invocation of grep guarantees
that grep will have at least two argument which will cause it to always
display file names.

Robert Perlberg
Dean Witter Reynolds Inc., New York
{murphy | philabs | chuo}!step!perl
	-- "I am not a language ... I am a free man!"



More information about the Comp.unix.questions mailing list