| TR(1) | General Commands Manual | TR(1) |
NAME¶
tr - Translate or delete characters
SYNOPSIS¶
tr [-c|--complement] [-d|--delete] [-s|--squeeze-repeats] [-t|--truncate-set1] [-h|--help] [-V|--version] [sets]
DESCRIPTION¶
Translate or delete characters
OPTIONS¶
- -c, --complement
- use the complement of SET1
- -d, --delete
- delete characters in SET1, do not translate
- -s, --squeeze-repeats
- replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character
- -t, --truncate-set1
- first truncate SET1 to length of SET2
- -h, --help
- Print help
- -V, --version
- Print version
- [sets]
EXTRA¶
Translate, squeeze, and/or delete characters from standard input, writing to standard output.
VERSION¶
v(uutils coreutils) 0.9.0
EXAMPLES¶
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 command's 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.
| 2026-06-04 |