Path: utzoo!attcan!uunet!rbj From: rbj@uunet.UU.NET (Root Boy Jim Cottrell) Newsgroups: comp.unix.questions Subject: Re: grep Message-ID: <110982@uunet.UU.NET> Date: 6 Nov 90 05:20:18 GMT References: <1990Oct23.123025.18012@kodak.kodak.com> <14225@smoke.BRL.MIL> Organization: UUNET Communications Services, Falls Church, VA Lines: 25 In article <14225@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: > find root_name -type f -print | xargs grep pattern /dev/null > >The extra argument to "grep" is to ensure that the filename will be >printed for each matching line. (Workaround for a wart in "grep"'s >design.) As usual, Doug has provided the correct answer, even tho he was by far not the first poster. I feel compelled only to add one small addendum: use the -l option of grep to print only the matching filenames. At the first match, we can quit this file. Note that this doesn't save much, and it is not clear from the question whether the filename only is wanted, or the line itself. We only save looking thru the files we found it in. >(If you don't have "xargs", complain to your vendor.) There is a public domain version in volume3 of comp.sources.unix. Others probably exist. But Doug is right, your vendor has no excuse not to have it. -- Root Boy Jim Cottrell