string conversion of Linux commands--tr

Source: Internet
Author: User

Name: TR

Location:/usr/bin/tr

Permissions: All Users

Function: can be used to delete text in a piece of information, or to replace the text information

Usage: TR [OPTION] ... SET1 [SET2]

Options:

-D Delete the SET1 string in the message

-S replaces duplicate strings


Example 1:

TR is replaced by default when there are no parameter options, consistent with the result of the-s parameter option.

$ last| TR  "[A-Z]" "[A-z]" |sed-n ' 1,5p ' CWJY1202 pts/0        : 0               SAT JAN 22:14 still   logged in REBOOT   SYSTEM BOOT  3.2.0-24-generic Sat Jan 21:45-23:48  (02:03)    CWJY1202 pts/0        : 0.0             Sat Jan 10 19:24 -Down   (00:00)    REBOOT   SYSTEM BOOT  3.2.0-24-generic SAT JAN 14:17-19:24  (05:07)    REBOOT   SYSTEM BOOT  3.2.0-24-generic FRI JAN  9 20:50-22:50  
$ last| Tr-s  "[A-Z]" "[A-z]" |sed-n ' 1,5p ' CWJY1202 pts/0        : 0               SAT JAN 22:14 STIL loged in   rebot   SYSTEM BOT  3.2.0-24-generic Sat Jan 21:45-23:51  (02:05)    CWJY1202 pts/0        : 0.0             Sat Jan 19:24-DOWN
    (00:00)    rebot   SYSTEM BOT  3.2.0-24-generic SAT JAN 14:17-19:24  (05:07)    Rebot   SYSTEM BOT  3.2.0-24-generic FRI JAN  9 20:50-22:50  (01:59)

Note: SET1 and SET2 are quoted, and both single and double quotation marks can be


Example 2:The TR command deletes the number in the A file output (this is not a modified file a)

$ cat apa:11:asa:32:capp:5:bstort:1:dpear:4:aahello:3:f$ Cat a| Tr-d "[0-9]" Pa::asa::capp::bstort::d pear::aahello::f


Note: tr-d "[0-9]" file syntax is incorrect and cannot be used to receive data streams through pipeline commands, etc.

Cond......

string conversion of Linux commands--tr

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.