Article View: comp.unix.shell
Article #1802Re: environmental vars in nawk
From: Richard Karasik
Date: Tue, 20 Nov 1990 02:10
Date: Tue, 20 Nov 1990 02:10
31 lines
1218 bytes
1218 bytes
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
Technical Details
Message-ID:
<344@octel.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!pacbell.com!pacbell!indetech!vsi1!octel!richardReferences:
<1990Nov15.150642.28752@cid.aes.doe.CA>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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