Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!finn
From: finn@eleazar.dartmouth.edu (Andy Behrens)
Newsgroups: comp.unix.questions
Subject: Re: accessing shell variables from within awk?
Message-ID: <10165@dartvax.Dartmouth.EDU>
Date: 24 Sep 88 01:20:19 GMT
References: <473@diamond.unix.ETA.COM> <69058@sun.uucp>
Sender: news@dartvax.Dartmouth.EDU
Reply-To: andyb@burcoat.uucp (Andy Behrens)
Distribution: na
Organization: Burlington Coat Factory Warehouse
Lines: 26

In answer to the question "How can I access a shell variable from within
awk", guy@gorodish.Sun.COM (Guy Harris) writes:
>
> You can put assignments on the command line,
> which might be a way to pass them to "awk", e.g.
>
>	awk -f awkfile foo="$foo"

If you are going to use this feature, be aware that many versions of awk
only recognize command-line assignments if they are followed by at least
one filename.  If you want awk to read from the standard input, explicitly
name it with '-', e.g.

	ls -l | awk -f awkfile foo="$foo" -

--
"Christ died for our sins.  Dare we make his martyrdom meaningless by
not committing them?"
					Andy Behrens
					andyb@burcoat.uucp
					(soon: andyb@coat.uucp)

internet: andyb%coat@dartmouth.edu
uucp:     {harvard,decvax}!dartvax!coat!andyb
bitnet:   andyb%coat@dartcms1
RFD 1, Box 116, East Thetford, Vt. 05043		 (802) 649-1258