Detailed explanation of tr command under linux system – linux operation and maintenance

Today I want to introduce to you a very commonly used command-tr. This command can be used to replace strings, delete specified characters, and compress multiple repeated characters to only one. In addition, this command supports pipelines. From the above function introduction, you should be able to feel that this command is very powerful. Next, let’s introduce this command: tr [option] parameter Common options are as follows: -c followed by a character range, indicating characters other than these characters -d deletes the specified character -s compresses the repeated character to only one The following passes a few Example to learn how to use this command String replacement This is the most basic function, when no option is added, it means string replacement, the command The format is: tr The original string needs to be replaced with the string Here, we often use the – symbol, which means continuous meaning. Let’s look at the case: # String replacement, replace lowercase letters with uppercase letters # echo hello, world | tr [a-z] [A-Z] HELLO, WORLD Delete characters Delete the specified characters through the option -d, and use the -d -c option to retain the specified characters. Let’s look at the case #…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索