In article <soi7hi$1jfv$
[email protected]>,
Steve Keller <
[email protected]> wrote:
Is there a way to pass options to awk scripts, like
awk -f script.awk -a
and handle the -a in my script? It seems when called like above, -a is >handled (and not understood) by awk itself. With
Here's a way that works pretty well. I don't know if I'd call it
"standard" or not...
--- Cut Here ---
#!/bin/dash
exec gawk -f /dev/fd/3 -- "$@" 3<< 'EOF'
BEGIN { print ARGV[1] }
# (rest of AWK script goes here)
--- Cut Here ---
Run as: ./this -a
A couple of notes:
1) /bin/sh on Debian Linux system is actually "dash". So, you could use /bin/sh instead. I prefer to always explicitly name my interpreter, rather than letting it fall to chance.
2) I really should have put in "EOF" at the end, but I left it out to illustrate that dash doesn't require it. bash does, well, sort of;
actually it works, but it generates a warning about it.
--
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy of the church so decides."
- Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)