How to read many input files in AWK?

advertisements

This question already has an answer here:

  • Awk: extract different columns from many different files 3 answers

I try to understand how to read many input files in AWK with this puzzle "How can I print 1st column from file 1 and 2nd column from file 2?

Input

$ cat test1
1   4
2   5
3   6
$ cat test2
a   b
c   d
e   f

Goal

$ awk **ANSWER**
1   b
2   d
3   f


awk 'NR==FNR{a[NR]=$1;next} {print a[FNR], $2}' file1 file2