Awk merge txt with database based on match
1
2
Entering edit mode
2.6 years ago
Mgs3 ▴ 30

I have a file (file1) with two column (ID and count) as such:

 APH(3'')-Ib 3486552
 mphA 7453
 acrB 6444
 kdpE 4982

and another file (file2) with a list of all the IDs

mphA
APH(3'')-Ib 
cruB
acrB 
kdpE 
vadA

I need to compare the IDs of file1 with the file2: if is present, print the read count. Output desired:

mphA 7453 
APH(3'')-Ib 3486552
cruB 
acrB 6444
kdpE 4982
vadA

I looked at similar question like this but i'm not able to adapt the script to my situation

bash awk card • 964 views
ADD COMMENT
1
Entering edit mode

Sounds like a job for join

ADD REPLY
2
Entering edit mode
ADD COMMENT
0
Entering edit mode

Thanks for the lead, i leave here the command i used for the future

join -a 2 file1 file2 > table
ADD REPLY

Login before adding your answer.

Traffic: 2573 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6