How Does Tr Work in Linux?
Contents

The tr command reads a byte stream from standard input (stdin), translates or deletes characters, then writes the result to the standard output (stdout). If we don’t pass any options to tr, it will replace each character in SET1 with each character in the same position in SET2.

How do I use tr in Linux?

10 tr Command Examples in Linux

  1. tr (short for translate) is a useful command line utility that translates and/or deletes characters from stdin input, and writes to stdout. …
  2. A simple tr command use case is to change all lower case letters in text to upper case and vice versa, as shown below.

How do you use tr?

tr stands for translate.

  1. Syntax. The syntax of tr command is: $ tr [OPTION] SET1 [SET2]
  2. Translation. …
  3. Convert lower case to upper case. …
  4. Translate braces into parenthesis. …
  5. Translate white-space to tabs. …
  6. Squeeze repetition of characters using -s. …
  7. Delete specified characters using -d option. …
  8. Complement the sets using -c option.
Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest