sort uniq

uniq 与sort是难兄难弟,有uniq常常需要sort命令,

这是因为当重复的行并不相邻时,uniq 命令是不起作用的,

即若文件内容为以下时,uniq 命令不起作用:

$ cat testfile1      # 原有内容 
test 30  
Hello 95  
Linux 85 
test 30  
Hello 95  
Linux 85 
test 30  
Hello 95  
Linux 85 

这时我们就可以使用 sort:

$ sort  testfile1 | uniq
Hello 95  
Linux 85 
test 30
posted @ 2022-12-27 11:09  原子切割员  阅读(28)  评论(0编辑  收藏  举报