tr is a common command of linux command, and its full name is "Text Replacer", which is used for text replacement. Tr is used to convert characters from standard input through replacement or deletion. Tr is mainly used to delete control characters in files or perform character conversion.
the format of the tr command for the most commonly used option is:
tr-c-d-s ["string1 _ to _ translate _ from"] ["string2 _ to _ translate _ to"] file
Here:
-c replaces this character set with the complement of the character set in string 1, and the character set is required to be ASCII.
-d deletes all input characters in string 1.
-s deletes all the repeated character sequences except the first one; That is, the repeated string is compressed into one string.
file is the conversion file name. Although other formats can be used for input, this format is the most commonly used.
character range:
when specifying the contents of string 1 or string 2, only a single character or string range or list can be used.
a string of characters in [a-z] a-z.
a string of characters in [a-z] a-z.
[-9] number string.
\octal is a three-digit octal number corresponding to a valid ASCII character.
[O*n] indicates that the character o is repeated a specified number of times n .. So [O*2] matches the string of OO.