Passing variables to gawk

Mike McManus mikemc at mustang.ncr-fc.FtCollins.NCR.com
Thu Jan 18 08:12:46 AEST 1990


I want to pass variables to a gawk program via the command line.  According to
the man page, all you need do is call gawk with <var>=<value> instead of file
names:

gawk -f foo.awk a=1 b=2 c=3 infile > outfile

and the variables a,b,c will be free to use in foo.awk (the gawk script), and
will be assigned the values 1,2,3.  I can't seem to get this to work!  When I
print the value of the variables inside a BEGIN{} block in foo.awk, they are all
set to 0.  Anybody have any experience with this that they'd like to share?

Thanks!
--
Disclaimer: All spelling and/or grammer in this document are guaranteed to be
            correct; any exseptions is the is wurk uv intter-net deemuns.

Mike McManus (mikemc at ncr-fc.FtCollins.ncr.com)  
NCR Microelectronics                
2001 Danfield Ct.                   ncr-fc!mikemc at ncr-sd.sandiego.ncr.com, or
Ft. Collins,  Colorado              ncr-fc!mikemc at ccncsu.colostate.edu, or
(303) 223-5100   Ext. 360           uunet!ncrlnk!ncr-sd!ncr-fc!garage!mikemc
                                    



More information about the Comp.unix.questions mailing list