Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!gatech!emcard!stiatl!meo From: meo@stiatl.UUCP (Miles O'Neal) Newsgroups: comp.unix.questions Subject: Re: accessing shell variables from within awk? Summary: an example Message-ID: <342@stiatl.UUCP> Date: 21 Sep 88 12:35:25 GMT References: <473@diamond.unix.ETA.COM> Distribution: na Organization: Sales Technologies Inc., Atlanta, GA Lines: 13 In article <473@diamond.unix.ETA.COM>, rscott@eta.unix.ETA.COM (Rich Scott) writes: > > How can I access a shell variable (to wit, a few environment > variables) from within "awk"? ... As a matter of fact, this is from a Sun 386i running 4.0, but should work with any real awk. We use it also under System V on a Convergent. usernum=`awk -F: '/^'$1'/ { print $3 }' /etc/passwd This is from a Bourne shell script we use. The $1 could just as easily be $fred or any variable name.