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

原文地址:https://www.cnblogs.com/sea-stream/p/10835473.html