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
awk -f script.awk -- -a
I get the -a actually into the ARGV variable. However, I cannot put the -- into the
#!/usr/bin/awk -f
and call
./script.awk -a
That seems to be impossible. Probably a shell wrapper
#!/bin/sh
exec awk -- '...' $*
will work. Second, how can I handle this in the script? It seems
BEGIN { if (ARGV[1] == "-a") { opt_a = 1; ARGV[1] = "" } }
does work. Yet another way would be to handle options in the shell
#!/bin/sh
if [ $1 == "-a" ]; then shift; opt=-vopt_a=1; fi
exec awk $opt '...' $*
Is there some standard way to do this?
Steve
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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 228:12:39 |
Calls: | 6,624 |
Calls today: | 6 |
Files: | 12,171 |
Messages: | 5,318,991 |