Re: grep question


Subject: Re: grep question
From: Matthew Kirkwood (weejock@ferret.lmh.ox.ac.uk)
Date: Sun Feb 27 2000 - 10:51:06 CST


On Sun, 27 Feb 2000, Paul Warren wrote:

> find ./ -name foo.bar -exec grep 'needle' {} \; -print

find . -name *.bar -print0 | xargs -0 grep bing.*bong /dev/null

will bemarginally quicker, as it will only fire off one grep process
for every 20 files (I think that's the default). And you'll see the
filename on the same line as the text, which is much nicer :)

Note that the /dev/null is necessary to stop grep from printing only
the matching line in the case that there are (N*20)+1 matching
filenames. (You could write that:

{ find . -name *.bar -print0 && echo /dev/null } |
                xargs -0 grep bing.*bong /dev/null

to save a few open() calls.)

Matthew.



This archive was generated by hypermail 2b25 : Sun Feb 27 2000 - 10:51:09 CST