-2

I'm running a shell script and line# 15 is:

grep "$var1$var2" somefilewithonly10000lines_letsay

and getting an error:

line 15: /bin/grep: Argument list too long

What's the limit for the grep command's pattern? -- which when I reach, gives me the above error message.

AKS
  • 16,482
  • 43
  • 166
  • 258
  • 1
    Post sample data and what your like to get out of it. You can have lots of stuff inside `var1` and `var2` that may make this fail. – Jotne Nov 01 '14 at 07:11
  • 1
    If you use Linux: Your complete commandline is longer than the value you get from: `getconf ARG_MAX` – Cyrus Nov 01 '14 at 08:52
  • @Jotne, I agree. value for $var1$var2 is very big. That's my question, what's the limit for that pattern size. For ex: $var1$var2 are like: "\([A-Z][A-Z][0-9][a-z][a-z].....many times may be more than 500 such patterns...somemorepatterns". Now, the ? is not, why don't I squeeze my pattern to "\([A-Za-z0-9]{2,}" or something, but ... what's the limit for that pattern size that grep can handle. Thanks in advance. – AKS Nov 03 '14 at 19:32
  • @Cyrus ARG_MAX on my machine is 131072. Do you mean this is the limit? http://www.in-ulm.de/~mascheck/various/argmax/ shows the same. – AKS Nov 07 '14 at 16:34

1 Answers1

1

THe following will tell the limit. Thanks Cyrus.

$ getconf ARG_MAX

More info: http://www.in-ulm.de/~mascheck/various/argmax/

AKS
  • 16,482
  • 43
  • 166
  • 258