I want to print only the lines in file2 that match file1, in the same order as they appear in file 1
file1
file2
desired output:
I'm getting the lines to match
but they are in sorted order, which is not what I want:
Can anyone help me out?
file1
Quote:
c2 c23 c14 c22 |
Quote:
c14 CGAGGCTG c2 CAGAGAGG c20 CTCGACTC c22 CGAGGCTG c23 AAGAGGCA |
Quote:
c2 CAGAGAGG c23 AAGAGGCA c14 CGAGGCTG c22 CGAGGCTG |
Code:
awk 'FNR==NR {a[$1]++}; FNR!=NR && a[$1]' file1 file2
Quote:
c14 CGAGGCTG c2 CAGAGAGG c22 CGAGGCTG c23 AAGAGGCA |