Actually, most newer implementations of awk (POSIX, Nawk, or Gawk) has the -v switch so you can interface awk and shell variables. Something like this should suffice:
awk -v name="$USER" '{ print name }' Or you can use a built-in associative array that accepts a current environment variable name as its index, which is quite handy for working with the shell:
awk '{ print ENVIRON["USER"] }' Another less efficient way would be to use the export command, though I won't give an example because I like the above methods, but it can be done.
For your problem, it's a little bit tricky. Maybe something like:
var=`awk '{ printf "%d", $1 }' filename` Not sure if that's what you were looking for, but working with the above information will get you where you need to go. This will substitue anything in back-quotes with the output of the command sequence within the two, thus, saving what should have gone to stdout to a variable. Sorry I couldn't be of much help.