grep

Root Boy Jim Cottrell rbj at uunet.UU.NET
Tue Nov 6 16:20:18 AEST 1990


In article <14225 at smoke.BRL.MIL> gwyn at 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 <rbj at uunet.uu.net>



More information about the Comp.unix.questions mailing list