我想查看文件的唯一行(只出现一次的行)但以下命令显示重复行:
uniq -u data.txt
#(it shows repeated lines)
我搜索了一下,发现如果你输入 sort
就可以,但为什么呢?
sort data.txt | uniq - u
#(it works, only shows unique lines)
最佳答案
它在手册页中是明确的:
Repeated lines in the input will not be detected if they are not adja- cent, so it may be necessary to sort the files first.
关于linux - 为什么我需要对 uniq 进行排序以删除重复行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38506066/