uniq — remove or count repeated lines
cheat sheet · Ubuntu 24.04 · GNU coreutils 9.4 https://lab.dimsanych.ru/en/wiki/uniq/Cheat sheet
-
sort file | uniqdrop repeats -
sort file | uniq -chow many times each line occurs -
sort file | uniq -c | sort -rnmost common first -
sort file | uniq -donly the lines that repeat -
sort file | uniq -uonly the lines without a twin -
sort file | uniq -ciignore case
Options
sort -u gives the same result as sort | uniq, but only uniq -c can count the
repeats. The full list is in man uniq.