Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    That's -vbenchmark="$benchmark" to assign the value of the shell variable (after expanding the \x sequences in it) to the awk variable. -vbenchmark=$benchmark without the quotes doesn't make any sense as that's invoking the shell's split+glob operator. Commented Dec 10, 2014 at 11:12
  • 1
    @StéphaneChazelas - but the original author got away with it in this instance as a split & glob of 30 returns 30. Obviously he/she hadn't read your excellent QA on the subject :-) Commented Dec 10, 2014 at 11:30
  • 2
    That's still invoking the split+glob operator which doesn't make sense. And it returns 30 unless IFS contains 3 or 0. For instance, if it's 0, that becomes awk -vbenchmark=3 '' '{thecode}' the files. The code becomes '' (which with most awk implementations make awk return immediately without an error); if it's 3, that becomes awk -vbenchmark= 0 '{the-code}' which will treat {the-code} as a file will cause awk to read that and the other files but output nothing as the code is now 0. Commented Dec 10, 2014 at 11:42
  • @StéphaneChazelas - fair point. That'll teach me to try and argue... In my defence, I my answer was only commenting on the original code - I didn't write it. Commented Dec 10, 2014 at 11:51