uniq重复行

[root@localhost ~]# more 1.txt 
this is a test  
this is a test  
this is a test  
i am tank  
i love tank  
i love tank  
this is a test  
whom have a try  
WhoM have a try  
you  have a try  
i want to abroad  
those are good men  
we are good men 

#uniq的一个特性,检查重复行的时候,只会检查相邻的行。重复数据,肯定有很多不是相邻在一起的
[zhangy@BlackGhost mytest]$ uniq -c 1.txt    
 3 this is a test
 1 i am tank
 2 i love tank
 1 this is a test          #和第一行是重复的
 1 whom have a try
 1 WhoM have a try
 1 you? have a try
 1 i want to abroad
 1 those are good men
 1 we are good men

#这个方式就解决了上面的问题,先进行sort以下
[root@localhost ~]# sort 1.txt | uniq -c
      1 i am tank  
      2 i love tank  
      1 i want to abroad  
      4 this is a test  
      1 those are good men  
      1 we are good men  
      1 whom have a try  
      1 WhoM have a try  
      1 you  have a try 

#数量排序 ,这个才是我想要的结果
[root@localhost ~]# sort 1.txt | uniq -c | sort -r
      4 this is a test  
      2 i love tank  
      1 you  have a try  
      1 WhoM have a try  
      1 whom have a try  
      1 we are good men  
      1 those are good men  
      1 i want to abroad  
      1 i am tank 
© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容