Quote:
Originally Posted by
Corona688
Shell variables are not awk variables. It won't see TIME if you don't do -v TIME="$TIME"
ls file* | awk '{ print $9 }' is something VERY different from awk '{ print $9 }' file* by the way. The second actually reads the contents of the files in question. Don't swap them.
$ FLAG=file_name
$ DIR=file_directory
$ awk -v flag="$FLAG" dir="$DIR" '{print flag, dir,$9}' test*
awk: cmd. line:1: fatal: cannot open file `{print flag,$9}' for reading (No such file or directory)
I am not really trying to print the time, I just want to ability to print another variable declared earlier. In the above example, I was trying to print two declared variables but it failed.