Find unique lines

后端 未结 11 1840
情书的邮戳
情书的邮戳 2020-12-23 10:46

How can I find the unique lines and remove all duplicates from a file? My input file is

1
1
2
3
5
5
7
7

I would like the result to be:

11条回答
  •  一向
    一向 (楼主)
    2020-12-23 11:38

    uniq has the option you need:

       -u, --unique
              only print unique lines
    
    $ cat file.txt
    1
    1
    2
    3
    5
    5
    7
    7
    $ uniq -u file.txt
    2
    3
    

提交回复
热议问题