As you know, awk cannot find the script itself.
If the script is marked as an executable, and if you have a which command, you should be able to:
awk -f `which script.awk` arg1
Alternatively and probably better, make a script into an executable:
#!/usr/bin/awk -f BEGIN { x = 23 } { x += 2 } END { print x }
Shebang needs the -f option to work with MacOS X 10.7.1, where I tested it:
$ script.awk script.awk 31 $
This gives you a standalone single phase solution.
source share