What does tr do?

translate or delete characters.

▸ Explain your own tr command →

tr examples, explained

$ tr -d '\n'

  • trtranslate or delete characters
  • -ddelete the given characters
  • \nan argument passed to the command

$ tr -s ' '

  • trtranslate or delete characters
  • -ssqueeze repeats of the given characters into one
  • an argument passed to the command

tr flags & options

-ddelete the given characters
-ssqueeze repeats of the given characters into one
-cuse the complement of the given set

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.