Where to start First steps track · 15 stages
Linux Labs

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 | uniq drop repeats
  • sort file | uniq -c how many times each line occurs
  • sort file | uniq -c | sort -rn most common first
  • sort file | uniq -d only the lines that repeat
  • sort file | uniq -u only the lines without a twin
  • sort file | uniq -ci ignore 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.

Loading…