[root@localhost demo]# cat luffy.txt 10.0.0.1 10.0.0.1 10.0.0.51 10.0.0.51 10.0.0.1 10.0.0.1 10.0.0.51 10.0.0.31 10.0.0.51 10.0.0.12 10.0.0.5 10.0.0.5 10.0.0.5 [root@localhost demo]# uniq luffy.txt #去除连续的重复行 10.0.0.1 10.0.0.51 10.0.0.1 10.0.0.51 10.0.0.31 10.0.0.51 10.0.0.12 10.0.0.5 [root@localhost demo]# sort -n luffy.txt | uniq #去除所有的重复行只留一个 10.0.0.1 10.0.0.12 10.0.0.31 10.0.0.5 10.0.0.51 [root@localhost demo]# sort -n luffy.txt | uniq -c #统计每行出现的次数 4 10.0.0.1 1 10.0.0.12 1 10.0.0.31 3 10.0.0.5 4 10.0.0.51 [root@localhost demo]# sort -n luffy.txt | uniq -c -d #找出文件中重复行,且统计出现次数 4 10.0.0.1 3 10.0.0.5 4 10.0.0.51 [root@localhost demo]# sort -n luffy.txt | uniq -c -u #找出只出现过一次的行 1 10.0.0.12 1 10.0.0.31
标签:10.0,0.1,demo,0.5,0.51,uniq From: https://www.cnblogs.com/wmqxlt/p/18656486