samedi 9 mai 2015

Comparing two tab delimited files and print matched rows

I have two big tabular files, file1 and file 2. I want to compare these two files and print matched rows as showed below.

file_1
ENSDARG00000000760
ENSDARG00000001015
ENSDARG00000001549
ENSDARG00000002445
ENSDARG00000003102
ENSDARG00000004594
ENSDARG00000004851

file_2
ENSDARG00000000151 ENSDART00000000160 2292 chovy.60083
ENSDARG00000000151 ENSDART00000151127 1470 chovy.60083
ENSDARG00000000175 ENSDART00000146636 1832 chovy.300567
ENSDARG00000000966 ENSDART00000001092 6325 chovy.254634
ENSDARG00000000966 ENSDART00000140618 6295 chovy.254634
ENSDARG00000001015 ENSDART00000001148 1791 chovy.388956
ENSDARG00000001015 ENSDART00000104891 1835 chovy.388956
ENSDARG00000001015 ENSDART00000141913 994 chovy.283553

my desired output:

ENSDARG00000001015 ENSDART00000001148 1791 chovy.388956
ENSDARG00000001015 ENSDART00000104891 1835 chovy.388956
ENSDARG00000001015 ENSDART00000141913 994 chovy.283553

my code:

grep -wFf file1.txt file2.txt > output.txt

I think it is not working..

Thank you for all your help!

Aucun commentaire:

Enregistrer un commentaire