linux上文件内容去重的问题uniq/awk 正则表达过滤操作

uniq:只会对相邻的行进行判断是否重复,不能全文本进行搜索是否重复,所以往往跟sort结合使用。

例子1

[root@aaa01 ~]# cat a.txt

12

34

56

12

[root@aaa01 ~]# cat a.txt|uniq >>au.txt

[root@aaa01 ~]# cat au.txt

12

34

56

12

例子2:

[root@aaa01 ~]# cat b.txt

10

46

32

10

[root@aaa01 ~]# cat b.txt|sort |uniq >>bu.txt

[root@aaa01 ~]# cat bu.txt

10

32

46

猜你喜欢

转载自www.cnblogs.com/qiangyuzhou/p/11820342.html