5 TR of the shell command

Source: Internet
Author: User

This is a magical command.

TR's whole spell is translate, that is, translation. The interesting thing is that we can make rules for translation. Use the following:

TR [option] set1 [Set2]

TR accepts input from the standard input and prints the result to standard output. The most basic function of TR is to replace the Set1 character set in order and substitute 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 specified by a character that corresponds to a set2.

TR supports some sets of similar regular expressions. Rote memorization must not be remembered, so you can refer to the man manual.

In all of these specific collections above, only [: Upper:] and [: Lower:] can be substituted 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 question, if set1 word than characters in Set2 character, then will Set2 inside the last character to correspond to all the extra characters.

If the character of the Set2 is than characters to Set1, discard more than the characters in the Set2.

See how the actual application works.

The contents of Test.txt are as follows:

This is the introduction of the TR command, 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.