passing arguments to awk scripts (Thanks & here is how)
David Datta
datta at vacs.uwp.wisc.edu
Mon Mar 11 06:40:07 AEST 1991
In tchrist at convex.COM (Tom Christiansen) sort-of writes:
>From the keyboard of datta at vacs.uwp.wisc.edu (David Datta):
>:Can it be done? Is there a way I can address a
>:command line argument within the script?
> Actually, gawk and nawk will also let you get at them, although
> awk won't. Check your man page
>--tom
I started with the man pages they make NO MENTION of parameter passing
BUT:
From: dwn at swbatl.sbc.com (David Neill)
If you want to pass variables to awk, it works like so:
awk '
{ script stuff using VAR1 and VAR2 }
' VAR1=something VAR2=somethingelse filenames
THANKS Dave!
For example, with the file "script"
-----------TOF
{
print var1
}
EOF-----------
calling
awk -f script var1="hi"
will work.
--
-Dave datta at vacs.uwp.edu [....uwm!uwpvacs!datta] The moon goes around in
orbit. It's the only place the moon does go. The moon only makes left
turns. To get anywhere else you have to get off. WANT TO GET OFF?
More information about the Comp.unix.misc
mailing list