1819872 Members
2652 Online
109607 Solutions
New Discussion юеВ

grep: arg list too long

 
SOLVED
Go to solution
GK_5
Regular Advisor

grep: arg list too long

I have 72000 files in a directory. When I do "grep test *" I get error "/usr/bin/grep: arg list too long"
Is there a limit on how many files has to be in a dir for grep to work.
Thanks in advance.
IT is great!
4 REPLIES 4
Hai Nguyen_1
Honored Contributor

Re: grep: arg list too long

The limit is on the length of the command line.

Hai
Rodney Hills
Honored Contributor
Solution

Re: grep: arg list too long

It's not a grep limit, but a shell limit.

Usually to deal with a large number of files you use the xargs command. example-

ls | xargs grep test

Will search for "test" in all the files in the current directory.

HTH

-- Rod Hills
There be dragons...
GK_5
Regular Advisor

Re: grep: arg list too long

Thanks I got it.
IT is great!
John Stiles
Frequent Advisor

Re: grep: arg list too long

depending on hpux version you are running, you may also have a kernel tuning fix. I ran into the arg list too long with hpux 10.20 with several commands, here's the notes I have:
HP-UX 11.00 ships with the arg length configured at its maximum by
default. On HP-UX 10.20 there is a tuning parameter "large_ncargs_enabled=1"
that will give you 100 times as many characters that you can pass to commands.
You need to be at PHKL_16410 or higher for this to be enabled and, as always,
current patches are highly recommended.

hope this helps.
John
all things must pass