Say I have the following data:
cat file
0.000 0.0 425.2 2.23
0.000 0.0 477.9 0.91
0.000 0.0 516.5 -0.41
0.000 0.0 566.5 -3.72
Within my awk script regress.awk
, I would like to set a variable temp
equal to the third field on the first line, so temp = 425.2
. Is there a simple way in awk to accomplish this? I can't figure out how to combine NF
and NR
. From the prompt I can use:
awk 'NR==1 {print $3}' file
Which will return 425.2, but I have no clue how to store that as a variable within an awk script. It seems like setting variables equal to a column is easy, but haven't ever seen anything about associating a specific row with them.