Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!iuvax!bsu-cs!dhesi
From: dhesi@bsu-cs.UUCP (Rahul Dhesi)
Newsgroups: comp.unix.questions
Subject: Re: accessing shell variables from within awk?
Message-ID: <4027@bsu-cs.UUCP>
Date: 20 Sep 88 16:22:02 GMT
References: <473@diamond.unix.ETA.COM>
Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi)
Distribution: na
Organization: CS Dept, Ball St U, Muncie, Indiana
Lines: 16

>How can I access a shell variable (to wit, a few environment
>variables) from within "awk"?

--cut here--cut here
#! /bin/sh
# How to use env variables from an awk script.  Just enclose the awk
# command in double quotes.  This will not work if the awk script is
# in a separate file.  Tested under 4.3BSD.

  awk "\
     BEGIN {mypath=\"$PATH\"; \
     printf \"my path is: [%s]\n\", mypath}" < /dev/null
--cut here--cut here

-- 
Rahul Dhesi         UUCP:  !{iuvax,pur-ee,uunet}!bsu-cs!dhesi