The TR command can replace, compress, and delete characters from standard input. It can literal a group of characters into another set, and is often used to write graceful single-line commands that are powerful.
TR (option) (parameter)
-C or--complerment: Supersedes all characters that are not part of the first character set;
-D or--delete: Deletes all characters belonging to the first character set;
-S or--squeeze-repeats: the consecutive repeating character is represented by a single character;
- t or--truncate-set1: Deletes the first character set more Change characters that are more than the second character set.
Converts an input character from uppercase to lowercase:
The echo "HELLO W[object Object" character set complements all characters from the input text that are not in the complement: the [Object object] complement contains the number 0~9, the space, and the newline character \ n, so it has not been deleted and all other characters have been deleted. Adding numbers using TR: [Object Object]
Delete the empty line of the specified file: Tr-s ' \ n '-s removes the duplicate element, leaving only the unique. The character classes that TR can use: [: Alnum:]: Letters and Numbers [: Alpha:]: Letters [: Cntrl:]: Control (nonprinting) characters [:d igit:]: Number [: Graph:]: Graphic characters [: lower:]: lowercase Letters [:p rint: ]: printable character [:p unct:]: Punctuation [: Space:]: blank character [: Upper:]: Uppercase [: xdigit:]: hexadecimal character tr ' [: Lower:] ' [: Upper:] '
A detailed description of TR usage in Linux