accessing shell variables from within awk?

Rahul Dhesi dhesi at bsu-cs.UUCP
Wed Sep 21 02:22:02 AEST 1988


>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:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi



More information about the Comp.unix.questions mailing list