I've looked around for awhile and found only either questions touching on the subject or providing me with an answer that does not work. Here's the question:
I'm working on an assignment for school that requires me to read in command line arguments for an awk script (which seems odd to begin with, but eh). We're using an older version of Unix and I'm running Bash. This awk only has the -f and -Fc options. Basically, I keep trying to do "awk -f awk_script arg1 arg2 arg3 arg4 arg5 arg6" but each time awk attempts to open arg1 as a file, which it isn't. An example I saw elsewhere addressing this was:
awk 'BEGIN { print "ARGV[1] = ", ARGV[1] }' foo bar
It was supposed to print "foo", but on this system I only get the output "ARGV[1] = awk: can't open foo". So, in summary, is there any way around this? Can an awk this old read command line arguments and use them for anything other than input files? The instructors notes file hinted at the above usage (of printing foo), but his program doesn't even run, so...
Any help would be greatly appreciated.
After Edit: Using SunOS 5.10 and this awk does not support the -v option, ONLY the -f and -Fc
$ awk 'BEGIN{ print "ARGV[1]=" ARGV[1]}' a b c- output ->argv[1]=a. Edit your question to include output fromuname -aandawk --version. Good luck. (you may not get a response for the --version, then your awk is pretty orginal equipment ; -) - shellternawk. (new awk). The book by awk's authors 'The Awk Programming Language', is about the "new" awk, and was published in 1988 but still highly recommended. 'Effective Awk Programming' (2001) is great too and covers many of the enhancments made to gawk (gnu-awk). Good luck. - shellter