I'd like to use awk to process multiple files such as
File 1:
1 1.045
2 1.033
3 1.029
File 2:
1 1.078
2 1.080
3 1.090
but I'm interested in storing a specific field from each file and then printing them all out on one line. For example, I'd like the second field of the second line in both files so that the output would be:
1.033 1.080
Can I get awk to store the field in question from each file in a separate variable or in separate fields of an array? I tried:
awk '
BEGIN{}
FNR==2{var1=$2;nextfile}
FNR==2{var2=$2}
END{printf "%6.3f %6.3f\n", var1,var2}' file1 file2
but this overwrites var1 with the field from the second file and never processes for var2.