i ask question example. have 2 files:
file1-
tr100013|c0_g1 tr100013|c0_g2 tr10009|c0_g1 tr10009|c0_g2 file2-
tr100013|c0_g1 at1g01360.1 78.79 165 35 0 301 795 19 183 2e-089 272 tr100013|c0_g2 at1g01360.1 78.79 165 35 0 301 795 19 183 2e-089 272 tr10009|c0_g1 at1g16240.3 77.42 62 14 0 261 76 113 174 4e-025 95.9 tr10009|c0_g2 at1g16240.2 69.17 120 37 0 1007 648 113 232 2e-050 171 tr29295|c0_g1 at1g22540.1 69.19 172 53 2 6 521 34 200 2e-053 180 tr49005|c5_g1 at5g24530.1 69.21 302 90 1 909 13 39 340 5e-157 446 expected output :
tr100013|c0_g1 at1g01360.1 78.79 165 35 0 301 795 19 183 2e-089 272 tr100013|c0_g2 at1g01360.1 78.79 165 35 0 301 795 19 183 2e-089 272 tr10009|c0_g1 at1g16240.3 77.42 62 14 0 261 76 113 174 4e-025 95.9 tr10009|c0_g2 at1g16240.2 69.17 120 37 0 1007 648 113 232 2e-050 171 i want compare 2 files. if first column same in both files, print whole line of second file common in both files.
using awk:
awk 'nr==fnr{a[$1]++;next};a[$1]' file1 file2 grep can same:
grep -wf file1 file2 -w match whole word only.
-f specifies file pattern.
Comments
Post a Comment