如何查找文件中的重复行?
How to find duplicate lines in a file?
我有一个带有 foillowing 数据的输入文件:
line1
line2
line3
begin
line5
line6
line7
end
line9
line1
line3
我试图找到所有重复的行,我试过了
sort filename | uniq -c
但似乎对我不起作用:
它给了我:
1 begin
1 end
1 line1
1 line1
1 line2
1 line3
1 line3
1 line5
1 line6
1 line7
1 line9
问题可能看起来重复 Find duplicate lines in a file and count how many time each line was duplicated?
但输入数据的性质不同。
请推荐。
使用这个:
sort filename | uniq -d
man uniq
我有一个带有 foillowing 数据的输入文件:
line1
line2
line3
begin
line5
line6
line7
end
line9
line1
line3
我试图找到所有重复的行,我试过了
sort filename | uniq -c
但似乎对我不起作用:
它给了我:
1 begin
1 end
1 line1
1 line1
1 line2
1 line3
1 line3
1 line5
1 line6
1 line7
1 line9
问题可能看起来重复 Find duplicate lines in a file and count how many time each line was duplicated? 但输入数据的性质不同。
请推荐。
使用这个:
sort filename | uniq -d
man uniq