passing command line arguments to awk

John Pierce jwp at sdchem.UUCP
Wed Jun 4 10:19:59 AEST 1986


Somebody:
> >awk -f awkfile arg1=$1 arg2=$2 inputfile
> >
> >will assign $1 to arg1, and $2 to arg2, inside the body of the awk program.
> >It is not possible to assign variable values in this manner to variables
> >that are used inside an action associated with the BEGIN pattern.

This is correct.

Somebody else:
> There is a much more general method to use. If you put the awk code inside of 
> the shell script [and use the shell to expand args]...

Also correct, but I'm not sure it's more "general", or useful.  It must get
very interesting typing five hundred lines of awk script into a file the shell
is going to parse first....

There were references to new versions of awk that appear to have considerably
more capabilities than the one distributed with BSD and Sys V (or at least the
version of Sys V on the campus 3B20s).  Can anybody tell me where they come
from, and whether or not they're available?  [Of course, I can probably guess
the answer to both of those.]
-- 
	John Pierce			Chemistry Dept, B-032
	jwp%chem at sdcsvax.ucsd.edu	University of California, San Diego
	sdcsvax!sdchem!jwp		La Jolla, CA  92093
					+1 619 452 4016



More information about the Comp.unix mailing list