uniq


Despite its name, uniq will not necessarly provide a unique list of values. It will collapse the adjacent equal values. If all the equal values are adjacent then it will really create a unique list. Sorting will reorder the original list so that the equal values will be next to each other.


examples/intro/uniq.txt
$ cat examples/intro/words.txt 
foo
foo
bar
foo
bar

$ uniq examples/intro/words.txt 
foo
bar
foo
bar

$ sort examples/intro/words.txt | uniq
bar
foo