shell uniq 统计,计数

 

uniq
选项与参数
-i:忽略大小写
-c:进行计数
[zhang@localhost ~]$ cat 2.txt
hello
Hello
WOrld
abc
abc
ABC
hello1

对2.txt进行sort后,进行uniq。
[zhang@localhost ~]$ cat 2.txt | sort | uniq
abc
ABC
hello
Hello
hello1
WOrld

进行sort,使用uniq忽略大小写
[zhang@localhost ~]$ cat 2.txt | sort | uniq -i
abc
hello
hello1
WOrld

进行sort,使用uniq进行计数
[zhang@localhost ~]$ cat 2.txt | sort | uniq -c
2 abc
1 ABC
1 hello
1 Hello
1 hello1
1 WOrld

posted @ 2019-05-08 22:34  anobscureretreat  阅读(2585)  评论(0编辑  收藏  举报