码迷,mamicode.com
首页 > 系统相关 > 详细

【刷题】面筋-shell:统计一个文件中重复的行和重复次数

时间:2020-05-08 13:28:17      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:csdn   --   net   txt   cat   链接   删除   sdn   shel   

使用cat+uniq命令

  • 其实就是统计每行重复多少次

    • 格式:uniq [options][file1 [files]]
  • uniq -c file

    • file中的重复行输出一次,并在每行前显示重复次数
  • uniq -d file

    • file中的重复行输出一次,但不输出唯一的行
  • uniq -u file

    • 只输出file中的唯一行
  • uniq file1 file2

    • 把file1中的重复的相邻行删除,并把每行的一个拷贝送到file2
  • 示例:

cat a.txt
1,2,3,3
4,4,4,1
4,4,4,1
2,4,4,1
cat a.txt|uniq -c
1 1,2,3,3
2 4,4,4,1
1 2,4,4,1
$ uniq -c a.txt
1 1,2,3,3
2 4,4,4,1
1 2,4,4,1

参考链接:

END

【刷题】面筋-shell:统计一个文件中重复的行和重复次数

标签:csdn   --   net   txt   cat   链接   删除   sdn   shel   

原文地址:https://www.cnblogs.com/anliux/p/12849742.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!