I want to compare two big files with different column and row numbers and print those line which have a common word (like KJ):
file1:
XT1 123 aa NR
XT2 444 bb GF
XT3 666 aa KJ
file2
fc KK pcn
wd CC KJ
output
XT3 666 aa wd CC KJ
I tried but I didn’t get anything:
awk 'FNR==NR{a[$4]=$3;next}{if (a[$3])print a[$3],$0}' file1 file2
Thank you in advance for your help
Based on the limited info you provided,
I assumed the following:
file2fits in memory as a hash of lines.file2.file1with the 3rd column offile2.It maintains the order of the lines as they appear in
file1.