tr - Translate or delete characters
tr
[-c|--complement]
[-d|--delete]
[-s|--squeeze-repeats]
[-t|--truncate-set1]
[-h|--help]
[-V|--version] [sets]
Translate or delete characters
use the complement of SET1
delete characters in SET1, do not translate
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character
first truncate SET1 to length of SET2
Print help
Print version
sets]Translate, squeeze, and/or delete characters from standard input, writing to standard output.
v(uutils coreutils) 0.10.0
Replace all occurrences of a character in a file, and print the result:
tr < path/to/file find_character replace_character
Replace all occurrences of a character from another commands output:
echo text | tr find_character replace_character
Map each character of the first set to the corresponding character of the second set:
tr < path/to/file abcd jkmn
Delete all occurrences of the specified set of characters from the input:
tr < path/to/file [-d|--delete] input_characters
Compress a series of identical characters to a single character:
tr < path/to/file [-s|--squeeze-repeats] input_characters
Translate the contents of a file to upper-case:
tr < path/to/file "[:lower:]" "[:upper:]"
Strip out non-printable characters from a file:
tr < path/to/file [-cd|--complement --delete] "[:print:]"
The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.