uniq 命令可以删除排序过的文件中的重复行,因此uniq经常和sort合用。
也就是说,为了使uniq起作用,所有的重复行必须是相邻的。
Options and parameters
-i :忽略大小写字符的不同;
-c :进行计数
-u :只显示唯一的行
Example:
[root@ localhost ~]# cat quchong.txt
one
one
two
three
four
four
1. After sorting delete duplicate rows, the first row position output while the number of repetitions of the line
[root@ localhost ~]# sort quchong.txt |uniq -c
2 four
2 one
1 three
1 two
2 shows only the presence of duplicate rows, and the number of repetitions of the line beginning of the line display
[root@ localhost ~]# sort quchong.txt |uniq -dc
2 four
2 one
The display does not only duplicate rows
[root@ localhost ~]# sort quchong.txt |uniq -u
three
two