Input file line matching

Hi there,
I have two input files. I need to match the last two columns of each line in File1 with the first two columns of a line in File2. Example:

File1

AAA BB 234 789
BBB CC 426 624
CCC DD 356 643

File2

766 332 12
234 789 64
122 633 23
426 624 88
777 453 22
356 643 92

Output

AAA BB 234 789 64
BBB CC 426 624 88
CCC DD 356 643 92

Is there an awk oneliner (my system does not recognize nawk)? Thanks so much!

Try this piece of code

awk 'NR==FNR{A[$1$2]=$0;next}{print $1" "$2" "A[$3$4]}' f2 f1
1 Like

Thanks very much... this works on my example. It doesn't seem to work on my actual files which are tab delimited. Would there be a quick modification? Sorry I hadn't mentioned this... thanks again.

Nevermind... got it! Thanks so much!

awk 'NR==FNR{A[$1$2]=$3;next}{print $0 OFS A[$3$4]}' OFS="\t" f2 f1