uniq Command Examples

Output the unique lines from a input or file. Since it does not detect repeated lines unless they are adjacent, we need to sort them first. More information: https://www.gnu.org/software/coreutils/uniq.

sort {{path/to/file}} | uniq

sort {{path/to/file}} | uniq -u

sort {{path/to/file}} | uniq -d

sort {{path/to/file}} | uniq -c

sort {{path/to/file}} | uniq -c | sort -nr