awk compare 2 columns, 2 files, output whole line

Hello,

I have not been able to find what I'm looking for via searching the forum. I could use some help with an awk script or one-liner to solve this simple problem.

I have two files. If $1 and $2 from file1 match $1 and $2 from file2, print the whole line from file2.

Example file1

-47.2 -19.0 18.12 13.78 0.36 0.56 0.001 ABPO
-38.8 9.0 24.02 18.91 0.41 0.48 0.001 ADIS
-0.5 38.3 19.06 16.84 0.29 0.12 0.003 ALAC

Example file2

-38.8 9.0 -1.78172 11.3782 0.01 0.01 0.01 31704
-0.5 38.3 -1.83964 11.2841 0.01 0.01 0.01 31701
-2.3 37.6 -1.82152 11.3152 0.01 0.01 0.01 31702
-47.2 -19.0 -1.80205 11.3466 0.01 0.01 0.01 31703
-2 37.6 -1.76099 11.41 0.01 0.01 0.01 31705
29.9 31.2 -1.7402 11.4417 0.01 0.01 0.01 31706

Output should be:

-47.2 -19.0 -1.80205 11.3466 0.01 0.01 0.01 31703
-38.8 9.0 -1.78172 11.3782 0.01 0.01 0.01 31704
-0.5 38.3 -1.83964 11.2841 0.01 0.01 0.01 31701

Thanks so much for your help.

nawk '{idx=$1 $2} FNR==NR{f1[idx];next} idx in f1' file1 file2
2 Likes
awk 'FNR==NR{A[$1,$2]=1;next} A[$1,$2]' file1 file2