用法: uniq –option file|stdin
作用:输出或者忽略文件中的重复行
#cat 1.txt
1.2
1.3
1.4
1.3
1.9
1.8
1.8
#uniq 1.txt
1.2
1.3
1.4
1.3
1.9
1.8
去掉了连续重复的行,如果只想保留文件中的唯一,“-u”
#uniq –u 1.txt
1.2
1.3
1.4
1.9
1.8
使用“-c”:去重复,并计算每行出现的次数
#uniq –c 1.txt
1 1.2
2 1.3
1 1.4
1 1.9
2 1.8
使用“-n”,编号
#uniq –n 1.txt
1 1.2
2 1.3
3 1.4
4 1.3
5 1.9
6 1.8
7 1.8
使用“-d”,只显示重复的行
#uniq –d 1.txt
1.3
1.8
用sort命令排序,再去重复,得到的结果也是唯一的
Sort –n 1.txt |uniq –c
1 1.2
2 1.3
1 1.4
2 1.8
1 1.9
07-17
07-17
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交