title: Uniq Command output: html_notebook
---
uniq [OPTION]... [INPUT [OUTPUT]]
-c, --count Prefix lines with a number representing how many times they occurred.
For example:
$ cat data.txt
aaaaaa
aaaaaa
cccccc
aaaaaa
aaaaaa
bbbbbb
$ cat data.txt | uniq
aaaaaa
cccccc
aaaaaa
bbbbbb
uniq
requires sorted input since it compares only consecutive lines:
$ cat data.txt | sort | uniq
aaaaaa
bbbbbb
cccccc