The tr (translate or delete characters) command is used to translate or delete characters in a text stream. It allows you to perform basic character-level transformations on text.
The syntax of the tr command is as follows:
tr [OPTIONS] SET1 SET2 .
Common options for the tr command include:
Here are some examples of using the tr command:
$ echo 'google' | tr 'g' 'G' ←Translate lowercase 'g' to uppercase 'G' $ echo 'google' | tr -d 'o' ←Delete all lowercase 'o' characters ggle $ cat file1 | tr 'a-z' 'A-Z' > file2 ←Convert the contents of "file1" to uppercase and save it as "file2" $ cat FILE.txt | tr '[:upper:]' '[:lower:]' ←Convert all uppercase letters to lowercase |