-2

Possible Duplicate:
Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?

I am using awk script inside a shell script and I am processing multiple files and for everytime I am getting the output from awk, processing it in shell and the feeding back the processd thing into awk script again.

But the problem here is, each time the data that is being processed is huge around 30000 lines which I am storing it in a single variable and I am passing into awk using the -v option.

So I am getting an error

/usr/bin/awk: Argument list too long

Any remedy of how to solve this .. And am I clear with the question

Community
  • 1
  • 1
User
  • 401
  • 2
  • 8
  • 15

1 Answers1

3

You're trying to pass too many arguments to awk. You shouldn't use -v to pass arbitrarily large amounts of data; feed it via a pipe to awk's standard input instead.

(I can't show you example code without seeing a snippet of your code, since I don't fully understand how you're currently handling your data.)

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Ya iI understood user point ...I have somehow resolved that error ...Now I am not passing any arguments to this but I am getting /usr/bin/ls Argument list too long... /usr/bin/expr ,, Argument list too long.. Any reason of why this error is because of ... As these statement's doesn't take arguments, then how come I am getign this error – User Jul 14 '12 at 18:25
  • @User: somehow, you are passing arguments to those commands. For example, how are you calling `ls`? – Fred Foo Jul 14 '12 at 19:02
  • Were you forgetting to quote your variable? `awk -v var="$data" '...'` – glenn jackman Jul 14 '12 at 19:02
  • No I havent .. My code is a loop it runs perfectly for the same ls comamnd without any error in the beginning and then it displays /ur/bin/ls error and then crashes .. I dun know the reason behind this – User Jul 15 '12 at 04:51