01 October 2017

执行uniq命令前,需要先用sort命令做排序,否则很有可能uniq会失效,因为uniq只会对相邻的内容做合并。

Linux manual

Note: ‘uniq’ does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use ‘sort -u’ without ‘uniq’. Also, comparisons honor the rules specified by ‘LC_COLLATE’.