using awk to select lines in file A, based on finding matches in file B

前端 未结 2 1245
醉话见心
醉话见心 2021-01-06 22:30

I have two files, file A looks like this:

1       101427      GENE|ACT-A      1       101589      GENE|ACT-B    0.0357
1       101427      GENE|ACT-A      1          


        
相关标签:
2条回答
  • 2021-01-06 23:06
    awk 'FNR == NR {keys[$1]; next} $3 in keys || $6 in keys' fileB fileA
    
    0 讨论(0)
  • 2021-01-06 23:27

    I would use the awk solution as it only has to examine each file once, but here's an alternative.

    { join -1 3 <(sort -k3 fileA) <(sort fileB) 
      join -1 6 <(sort -k6 fileA) <(sort fileB)
    } > output
    
    0 讨论(0)
提交回复
热议问题