Limits of grep?

Derek Martin ddm at mclinux.com
Tue Sep 26 10:37:16 EDT 2000


On Tue, 26 Sep 2000, Subba Rao wrote:

> 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.

The problem is not that grep has a limit, but that the command line can
only have a certain number of characters... I think it's either 1k or 4k
but I don't remember.  

When you do something like

  grep 'a' *

the * gets expanded BY THE SHELL to the name of every file in the current
directory.  If that exceeds the maximum length of a command line, you
lose.

An alternate strategy might be to do something like:

  find . -exec grep 'a' {} \;

Also, at least with GNU grep, there's the --recursive option which will
let you grep a directory recursively... you might try that too.  Alternate
ways of specifying this are -r, and -d recurse, which may or may not be
available under commercial U*ixes.


-- 
Derek Martin
Senior System Administrator
Mission Critical Linux
martin at MissionCriticalLinux.com 

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).



More information about the Discuss mailing list