AWK: Comparing two different columns in two files
问题 I have these two files File1: 9 8 6 8 5 2 2 1 7 0 6 1 3 2 3 4 4 6 File2: (which has over 4 million lines) MN 1 0 JK 2 0 AL 3 90 CA 4 83 MK 5 54 HI 6 490 I want to compare field 6 of file1, and compare field 2 of file 2. If they match, then put field 3 of file2 at the end of file1 I've looked at other solutions but I can't get it to work correctly. Desired output: 9 8 6 8 5 2 0 2 1 7 0 6 1 0 3 2 3 4 4 6 490 My attempt: awk 'NR==FNR{a[$2]=$2;next}a[$6]{print $0,a[$6]}' file2 file1 program just