[techtalk] Limits of grep?

Julie jockgrrl at ix.netcom.com
Wed Sep 27 07:42:20 EST 2000


From: Lotta Loytonen <lotta at infa.abo.fi>
> On Tue, Sep 26, 2000 at 06:59:49AM -0500, Julie wrote:
> > You're exceeding the longest argument list which can be passed
> > to a command via the exec() call.  This is NCARGS_MAX.
> >
> > > What is the file argument limit for grep? I guess you need the grep
source
> > > for this. I did not find any information in the man page.
> >
> > Nope, this is a kernel limit.
> >
> > > Are there any other recommended tools to search through such large
list of
> > > files?
> >
> > find . -type f -print | xargs grep <pattern> /dev/null
> >
>
> I have a similar problem to Subba's but with an additional twist. It's
> this directory with at worst ~50000 text files that are all called
> some number.letter, for example 1056.a or 5785.l. I usually need to
> grep only in f ex *.l or *.a. Is there any way to accomplish this? For
> now I've just done a ls < xargs grep foo, because it seems to be
> faster than find and there aren't any binary files, but it's kind of
> silly to grep in everything when it's really just the results from *.l
> I want.

This is why the Goddess invented regular expression file name
matching.

find . -name '<name regex>' -print | xargs grep <regex> /dev/null

> Oh yeah, it's on AIX so it comes with its own grep etc, but we do have
> a lot of gnu utilities installed too.

AIX's "find" and "grep" are both more than up to the task.

-- Julie (Did I mention I work on AIX?).






More information about the Techtalk mailing list