[techtalk] Limits of grep?

Lotta Loytonen lotta at infa.abo.fi
Wed Sep 27 10:53:39 EST 2000


On Tue, Sep 26, 2000 at 06:59:49AM -0500, Julie wrote:
> From: Subba Rao <subb3 at attglobal.net>
> > I have a directory of 10000+ text files and would like to search for
> > some strings in these files. When I tried using "grep" command with an
> > asterisk, I get the error message somthing to the effect,
> >
> > "File argument list too long"
> 
> 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.  

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. 


Lotta

-- 
You are lost in Swamps of Despair




More information about the Techtalk mailing list