Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!pacbell.com!pacbell!indetech!vsi1!octel!richard From: richard@octel.UUCP (Richard Karasik) Newsgroups: comp.unix.shell Subject: Re: environmental vars in nawk Message-ID: <344@octel.UUCP> Date: 20 Nov 90 02:10:47 GMT References: <1990Nov15.150642.28752@cid.aes.doe.CA> Distribution: na Organization: Octel Communications Inc., Milpitas Ca. Lines: 31 In article <1990Nov15.150642.28752@cid.aes.doe.CA> afsijsf@cidsv01.cid.aes.doe.CA () writes: > > How do you reference an environmental variable (which >happens to be a pathname) inside a nawk script? eg: > >setenv CMCARC=/a/b/c > >The awk script could be like this: > >BEGIN { aa = $CMCARC > etc... My email bounced -so here.. use the ARGV variables and include environment variable on the command line to invoke nawk ie: nawk -f foobar $CMCARC .... in this case ARGV[0] is awk, ARGV[1] is $CMARC. since command lines expand, you should get what you want. ie your first awk line should look like BEGIN { aa = ARGV[1] .... Dont forget to reset ARGV [2] ="" or you'll end up interpreting $CMCARC as a file to be read in. Richard