uniq命令

1.uniq命令

将重复的数据合并在一起。



2.uniq命令的使用

语法:

uniq [选项] 文件


选项:

-i:忽略大小写

-c:进行计数,有几条重复的数据。



3.实例

将文件进行合并,因为没有挨着,所以并没有合并。

[root@localhost ~]# uniq 1.txt

111

222

111

222

aaa

sss

aaa

sss


先进行排序,然后进行合并。并计数。

[root@localhost ~]# sort 1.txt |uniq -c

2 111

2 222

2 aaa

2 sss


sort -u选项同样可以达到同样的效果。

[root@localhost ~]# sort 1.txt -u

111

222

aaa

sss


猜你喜欢

转载自blog.51cto.com/11060853/2107271