how to show lines in common (reverse diff)?

前端 未结 7 1002
花落未央
花落未央 2020-11-27 10:35

I have a series of text files for which I\'d like to know the lines in common rather than the lines which are different between them. Command line unix or windows is fine.

7条回答
  •  抹茶落季
    2020-11-27 11:02

    Easiest way to do is :

    awk 'NR==FNR{a[$1]++;next} a[$1] ' file1 file2
    

    Files are not necessary to be sorted.

提交回复
热议问题