cmdxray / commands / uniq

What does uniq do?

report or omit repeated adjacent lines.

▸ Explain your own uniq command →

uniq examples, explained

$ uniq -c sorted.txt

  • uniqreport or omit repeated adjacent lines
  • -cprefix each line with the number of times it occurred
  • sorted.txtan argument passed to the command

$ sort names.txt | uniq -d

  • sortsort lines of text
  • names.txtan argument passed to the command
  • |pipe — send this command's output into the next command
  • uniqreport or omit repeated adjacent lines
  • -dprint only lines that are repeated

uniq flags & options

-cprefix each line with the number of times it occurred
-dprint only lines that are repeated
-uprint only lines that are never repeated
-iignore case when comparing lines
-fskip the first N fields when comparing
-sskip the first N characters when comparing
-wcompare no more than N characters per line

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.