Path: utzoo!attcan!uunet!murphy!step!perl From: perl@step.UUCP (Robert Perlberg) Newsgroups: comp.unix.questions Subject: Re: grep Summary: find . ! -type d -print|xargs grep xyz /dev/null Message-ID: <1701@number1.step.UUCP> Date: 25 Oct 90 13:36:50 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> Organization: Dean Witter Reynolds Inc., New York Lines: 20 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? 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!"