5 TR of the shell command

Source: Internet
Author: User

This is a wonderful command.

TR's whole spell is translate, that is, translation. Interestingly, we are able to make rules for translation. Use methods such as the following:

TR [option] set1 [Set2]

TR accepts input from standard input. The results are then printed to standard output. The main function of TR is to replace. The Set1 character set is ordered and replaced by the character set in Set2.

The following is a look at the parameters of tr.

-D Deletes the character of the Set1 specified later.

-C takes set of complement.

-S replaces the SET1 with the specified consecutive character as a set2 in the corresponding character.

TR supports some sets of similar regular expressions.

Rote memorization must not be remembered. So I can take a look at the man manual.

In all of these specific collections above. Only [: Upper:] and [: Lower:] can be replaced as many-to-many, the term is called the conversion character. Because the characters of these two sets are ordered sequentially.

The other characters can only be used for many-to-one substitution.


There is a problem, assuming that the Set1 word than characters in the Set2 character, then the Set2 inside the last character to the corresponding all the more characters.

Assuming that Set2 's character than characters in Set1, it discards more than the characters in the Set2.

See how the actual application works.

The contents of the Test.txt are as follows:

The above is a brief introduction to the TR command, the so-called practice makes perfect.

This is especially true for learning shell commands, and it's easy to remember more times.


5 TR of the shell 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.