The TR, tee of the Linux command

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.