awk one liner
awk '{if(NR>1)system("grep -w ^"$2" <file2>");}' <file1>
Also many other solutions are there, check join
or in awk
itself without using grep
, simply by storing the first files content in an array, it can be done,
1
solved bash: compare 2 files, then output third file with same pattern [closed]