[clue-tech] recursive grep

chris fedde chris at fedde.us
Mon Oct 18 16:59:08 MDT 2010


Mixing ideas from this thread and a previous one

  find2perl /haystack -type f -! -type B |  perl | xargs grep needle

xargs will cause grep to handle many files with one grep process.
This will be faster than forking a grep per child as "--exec grep
{}\;" does.

A real speed daemon might want to replace xargs with parallel.

   find2perl /haystack -type f -! -type B |  perl | parallel grep needle

Parallel is a perl script that will manage one child grep process per
system core.   As long as much of the data is in ram file buffers from
the optimistic block fetch typical of linux then this may be quite a
bit faster.

On Mon, Oct 18, 2010 at 2:18 PM, David L. Willson <DLWillson at thegeek.nu> wrote:
> Does anyone have a good idea for "find absolutely every file in haystack/,
> that mentions needle"?
>
> "grep -R needle /etc/*" and "grep -R needle /var/*"seem to run forever.
>
> I think it's a "find /etc -xtype f -exec grep ... something, but I can't
> think of the right something.
>
> David L. Willson
> Trainer, Engineer, Enthusiast
> MCT MSCE Network+ A+ Linux+ LPIC-1 NovellCLA UbuntuCP
> tel://720.333.LANS
>
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://cluedenver.org/mailman/listinfo/clue-tech
>


More information about the clue-tech mailing list