Path: utzoo!attcan!uunet!timbuk!cs.umn.edu!uc!noc.MR.NET!msi.umn.edu!umeecs!umich!samsung!usc!wuarchive!zaphod.mps.ohio-state.edu!swrinde!ucsd!ucbvax!mtxinu!sybase!satori!robert From: robert@satori.sybase.com (Robert Garvey) Newsgroups: comp.unix.questions Subject: Re: grep Summary: use -l option of grep Keywords: Use find Message-ID: <11486@sybase.sybase.com> Date: 25 Oct 90 23:52:14 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> <1990Oct23.143247.5639@lgc.com> Sender: news@Sybase.COM Organization: Sybase, Inc. Lines: 17 In article <1990Oct23.143247.5639@lgc.com> max@lgc.com (Max Heffler) writes: >Try this: > > cd x where x is head of tree to search > find . -type f -exec grep xyz {} /dev/null \; | tee $HOME/xyz.out > >The /dev/null is to cause grep to report back the filenames where the string >is found, since grep will not report the filename for a single argument. I'd recommend adding the -l option to the grep command. Lines that contain the pattern are not output, only the name of the file(s) that have at least one instance. This option works as you'd like if grep is searching on a single file; its name is output. Robert Garvey Sybase, Inc robert@sybase.com 6475 Christie Ave {sun,lll-tis,pyramid,pacbell}!sybase!robert Emeryville, CA 94608-1010