> From: Mitchell Pryor
>
> This may not be a bug, but it seems like one to me.
>
> Script:
>
>
> #!/bin/gawk -v num=$1 -f
> BEGIN {
> print "num=" num
> }
>
> When I try to execute this script as follows why does it say that 'num' is an illegal variable?
>
> ./myscript <some-number> <some-text-file>
>
> Is '-f' the only allowable switch for gawk within an executable format? I can't find any documentation addressing this specific situation.
>
>
> Thanks for any help you can
give.
This has nothing to do with awk but rather with the way your OS parses the !# line. Short answer is, you're on a system that takes everything following the first word as a single argument. Linux behave this way.
Long answer here:
http://www.in-ulm.de/~mascheck/various/shebang/ , the table at the bottom lists the behavior of different operating systems.
Note that even if the system parsed the individual arguments, I'm not sure the script would work the way you want anyway, due to the $1 substitution.