awk & variables

Mark Charles Marsh mark at siva.UUCP
Sat Jun 3 16:19:11 AEST 1989


> In article <23206 at dhw68k.cts.com> jaff at dhw68k.cts.com (Mark Jaffe) writes:
> >Awk seems to be lacking something, but maybe it's really there.  I want to
> >match a pattern that I don't know until I execute the script, so I want to
> >pass in a pattern to match in a variable.  I can't get this to work!  Here's

I am using this and it works. 

Try:
	<input stream> | awk -f <awk program> VAR=$THING -

or

	awk -f <awk program> VAR=$THING <input file>

and reference your variable in your awk program as:

	printf("var=[%s]\n",VAR);

Good luck.
-- 
"Off by an order of magnitude; my specialty!" |\    /| |  /  |  \      /
          ...!ames!pacbell!sactoh0!siva!uumgr | \  / | | /   |   \    /
                  ...!csusac!unify!siva!uumgr |  \/  | | \   |    \  /
                                   Mark Marsh |      | |  \  |     \/



More information about the Comp.unix.wizards mailing list