0

I'm getting "ambiguous redirect " error in shell script even if I use double Quotes suggested by Getting an "ambiguous redirect" error. I'm passing it as shell variable

awk -F ',' -v grep_values="${grep_value}" '$6==grep_values' file
awk -F ',' -v grep_values="${grep_value}" '$6=="${grep_values}"' file

Any suggestions.

Community
  • 1
  • 1
Hideandseek
  • 271
  • 1
  • 4
  • 17
  • Do you know the value of `${grep_value}` when you get the error? – jas Jan 28 '16 at 10:56
  • It contains spaces. Like abc def. It's working find without spaces – Hideandseek Jan 28 '16 at 10:57
  • Spaces or not, I can't reproduce any error. (Your first statement is the correct one; in the second the `${grep_values}` will be taken quite literally.) In any case, the ambiguous redirect error is really from bash and not awk, no? Is there a larger context you can show that might give more of a hint where this error is coming from? – jas Jan 28 '16 at 11:56
  • 1
    Always use the first script, never the second one or any other attempt to let a shell variable expand inplace to become part of an awk script. There is nothing in either awk script that would cause the error you are getting - look elsewhere in your shell script that calls it, you probably have a mismatched single or double quote somewhere. Reduce the shell script to the smallest possible example that reproduces the problem and you'll probably spot it right away, if not post that script here for help. – Ed Morton Jan 28 '16 at 15:35
  • 1
    I don't see a single redirection in any of that code, much less an ambiguous one. – e0k Jan 28 '16 at 18:42

0 Answers0