accessing shell variables from within awk?

Richard A. O'Keefe ok at quintus.uucp
Tue Sep 20 17:59:38 AEST 1988


In article <473 at diamond.unix.ETA.COM> rscott at eta.unix.ETA.COM (Rich Scott) writes:
>
>	How can I access a shell variable (to wit, a few environment
>variables) from within "awk"?

Try
	awk -f script var=value... var=value file...
This is in the SunOS manual page, and worked on a 4.2 system which didn't
have it in the manual page.  Or use a temporary file:
	cat >$$.awk <<EOF
	# put your script here
	EOF
	awk -f $$.awk ....
	rm $$.awk



More information about the Comp.unix.questions mailing list