Unix/Linux:如何查看文件中的重复行
时间:2019-08-20 17:58:32 来源:igfitidea点击:
要查找文件中的重复行,请使用下面给定的命令
sort file-name|uniq -c -d
其中
sort –对文本文件行进行排序
file-name -查找的文件
uniq -报告或者忽略重复行
对于uniq命令,我们使用以下给定参数:
-c、 –按出现次数计算行数
-d、 –只打印重复行
示例
Hyman@linuxworld:/tmp$ cat list
Air
water
soil
chemical
seas
red
green
flower
seas
towers
trees
languages
flower
boat
water
Hyman@linuxworld:/tmp$
Hyman@linuxworld:/tmp$ sort list |uniq -c -d
2 flower
2 seas
2 water
Hyman@linuxworld:/tmp$

