TR Replace or delete characters
-D Delete Character
-C uses a complement of the first character set, which is the inverse
-S retains the first character of a continuous character, removing other characters
View Test Files Tr.txt
[email protected] tmp]# cat Tr.txt
ABC Oldboy FFF
Erhait
Dfab DD ACR
Example:
1 The ABC in the file is converted to XYZ
[[Email protected] tmp]# TR ' abc ' XYZ ' <tr.txt
XYZ Oldyoy FFF
Erhait
DFXY DD XZR
The ABC and XYZ one by one are replaced, and are global replacements.
2 Replace lowercase letters with uppercase
[[Email protected] tmp]# TR ' [A-z] ' [A-z] ' <tr.txt
ABC Oldboy FFF
Erhait
Dfab DD ACR
3 Delete Oldboy
[Email protected] tmp]# tr-d Oldboy <tr.txt
AC FFF
Erhait
FA ACR
Delete all the Oldboy, including the 6 letters
4 Replace all lowercase letters with * #和所有非小写字母的字符替换为 #
[[Email protected] tmp]# TR ' [A-z] ' # ' <tr.txt
Erhait
[[email protected] tmp]# tr-c ' [A-z] ' # ' <tr.txt
abc#oldboy#fff####### #dfab #dd#acr#[[email protected] tmp]#
Tee Multi-directional, output to the screen at the same time, output to a file
-A Append
Example
[Email protected] tmp]# echo 123|tee-a tr.txt
123
[email protected] tmp]# cat Tr.txt
ABC Oldboy FFF
Erhait
Dfab DD ACR
123
The TR, tee of the Linux command