Comparing two files in linux terminal

后端 未结 10 1173
一生所求
一生所求 2020-12-22 17:31

There are two files called \"a.txt\" and \"b.txt\" both have a list of words. Now I want to check which words are extra in \"a.txt\

10条回答
  •  时光取名叫无心
    2020-12-22 17:43

    Use comm -13 (requires sorted files):

    $ cat file1
    one
    two
    three
    
    $ cat file2
    one
    two
    three
    four
    
    $ comm -13 <(sort file1) <(sort file2)
    four
    

提交回复
热议问题