Comparing two unsorted lists in linux, listing the unique in the second file

前端 未结 4 1060
无人共我
无人共我 2021-01-29 22:36

I have 2 files with a list of numbers (telephone numbers).

I\'m looking for a method of listing the numbers in the second file that is not present in the first file.

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-29 23:21

    You need to use comm:

    comm -13 first.txt second.txt
    

    will do the job.

    ps. order of first and second file in command line matters.

    also you may need to sort files before:

    comm -13 <(sort first.txt) <(sort second.txt)
    

    in case files are numerical add -n option to sort.

提交回复
热议问题