UnixDroid

Text · Linux command

tr command in Linux

What does tr do?

tr translates or deletes characters — e.g. lowercase to uppercase, or ROT13.

tr SET1 SET2

Most useful options

OptionWhat it does
-ddelete characters
-ssqueeze repeats

tr examples

$ echo hello | tr a-z A-Z Try it ›

HELLO

$ echo 'URYYB' | tr A-Za-z N-ZA-Mn-za-m Try it ›

ROT13 decode

$ tr -d '\r' < win.txt Try it ›

remove Windows line ends

In security work

tr solves simple CTF ciphers like ROT13 in one line.

Questions about tr

How do I convert to uppercase in Linux?

echo text | tr a-z A-Z