Kolam Ayer MakersLinux Foundations

uniq

Use

sort names.txt | uniq

What It Does

uniq removes adjacent duplicate lines.

Examples

Collapse duplicates after sorting:

sort names.txt | uniq

Count duplicates:

sort names.txt | uniq -c

Show only duplicate lines:

sort names.txt | uniq -d

Watch Out

If duplicates are not next to each other, uniq will not remove them. That is why sort | uniq is common.

Docs Pointers