[Techtalk] real life kewl text-processing and regexps samples wanted

Daniel lc-techtalk at nada.refused.cc
Sat Jan 10 05:36:51 EST 2004


On Fri, Jan 09, 2004 at 07:14:51PM -0800, Elena Bevell wrote:
> I like this recursive grep that I found somewhere:
> 
> find  . -type f -exec grep "thing-to-find" {} \;

This works, but it is horribly slow.

  find . -type f -print0 | xargs -0 grep "thing-to-find"

is a lot faster. The first one forks and execs' on every file it
finds. The second one gives grep dozens of files, without the
fork and exec overhead.

But there is a difference, if you call grep on more than one
file, the filename is prefixed to the search results. If you
don't want this, use:

  find . -type f -print0 | xargs -0 cat | grep "thing-to-find"


                                                -Daniel-


More information about the Techtalk mailing list