I’m trying to debug a shell script that calls an awk file. Which is a nightmare, cause I’ve never used either before, nor am I very fluent with linux, but anyway
A dev made an awk file and is trying to run it in a shell script.
To try and run it from a separate location, without needing to specify the exact location, they put the awk script in a folder that’s in the PATH variable. So that awk file should be available everywhere, right?
When you run it like this…
awk -f script.awk arg1
…can awk find that script? It spits out an error, when the shell script tries to run that awk command:
awk: fatal: can’t open source file `script.awk’ for reading (No such file or directory)
As you know,
awkcan’t find the script itself.If the script is marked as executable, and if you have a
whichcommand, then you should be able to do:Alternatively, and probably better, make the script into an executable:
The shebang needs the ‘
-f‘ option to work on MacOS X 10.7.1 where I tested it:That gives you a self-contained single-file solution.