GML-VS
GML-VS

Reputation: 1100

How to get search IDs from the file (awk)

I have a file(file1) with some IDs like ns:m.050fh (one ID per line and I can't use regexp here).

I need to print out the lines from the second file(file2, csv, separated by tab) where the first column of the second file = some ID from the first file.

Is it possible with awk or grep?

Something like (pseudo code):

        awk -F'\t' '$1 == $(file1)' file2

Upvotes: 0

Views: 264

Answers (1)

Kent
Kent

Reputation: 195209

try this:

awk -F'\t' 'NR==FNR{a[$0];next} $1 in a' file1 file2

file1 is the ID-file.

the line above will print all lines from file2, which the id exists in file1.

Upvotes: 2

Related Questions