cmdxray / commands / sort

What does sort do?

sort lines of text.

▸ Explain your own sort command →

sort examples, explained

$ sort -k2 -n -r data.txt

  • sortsort lines of text
  • -k2sort by the given field/key
  • -nsort numerically, not alphabetically
  • -rreverse the result order
  • data.txtan argument passed to the command

$ sort -u -f names.txt

  • sortsort lines of text
  • -uoutput only the first of equal lines (unique)
  • -ffold case — treat lower and upper case alike
  • names.txtan argument passed to the command

sort flags & options

-nsort numerically, not alphabetically
-rreverse the result order
-uoutput only the first of equal lines (unique)
-hsort human-readable sizes (2K, 1G)
-ksort by the given field/key
-tuse the given field separator
-ffold case — treat lower and upper case alike

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.