In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the tr command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Linux common command tr command is used to convert or delete characters in the file. Tr instruction reads data from the standard input device, and after string translation, the result is output to the standard output device.
Syntax tr [- cdst] [--help] [--version] [first character set] [second character set] tr [OPTION]... SET1 [SET2] parameter description:
-c,-complement: invert the setting character. That is, the part that conforms to the SET1 will not be processed, and the rest of the part that does not conform will be converted.
-d,-delete: delete instruction characters
-s,-squeeze-repeats: reduce consecutive repeated characters to a specified single character
-t,-truncate-set1: cut the specified range of SET1 to equal the length set by SET2
-help: displays program usage information
-version: displays the version information of the program itself
Range of character sets:
Character NNN of\ NNN octal value (1 to 3 is octal value character)
\ backslash
\ a Ctrl-G ringtone
\ b Ctrl-H backspace character
\ F Ctrl-L walk to change pages
\ nNew line of Ctrl-J
\ r Ctrl-M enter
\ t Ctrl-I tab key
\ v Ctrl-X horizontal tabs
CHAR1-CHAR2: the assignment of a range of characters from CHAR1 to CHAR2, based on the order of ASCII codes, only from small to large, not from large to small.
[CHAR*]: this is a SET2-specific setting that repeats the specified characters to the same length as SET1
[CHAR*REPEAT]: this is also a special setting for SET2. The function is to repeat the specified characters up to the set number of REPEAT (the number of REPEAT is calculated in octal system, starting with 0)
[: alnum:]: all alphabetic characters and numbers
[: alpha:]: all alphabetic characters
[: blank:]: all horizontal spaces
[: cntrl:]: all control characters
[: digit:]: all numbers
[: graph:]: all printable characters (excluding spaces)
[: lower:]: all lowercase letters
[: print:]: all printable characters (including spaces)
[: punct:]: all punctuation characters
[: space:]: all horizontal and vertical spaces
[: upper:]: all capital letters
[: xdigit:]: all hexadecimal numbers
[= CHAR=]: all match the specified characters (the CHAR in the equal sign represents the characters you can customize)
Instance converts all lowercase letters in the file testfile to uppercase letters. In this case, you can use the following command:
Cat testfile | the contents of tr amurz A-Ztestfile file are as follows:
$cat testfile # testfile original content Linux networks are becoming more and more common,but scurity is often an overlooked issue. Unfortunately, in today's environment all networksare potential hacker targets, fro0m tp-secret military research networks to small home LANs. Linux Network Securty focuses on securing Linux in anetworked environment, where the security of the entire network needs to be consideredrather than just isolated machines. It uses a mix of theory and practicl techniques toteach administrators how to install and use security applications, as well as how theapplcations work and why they are necesary. After case conversion using the tr command, you get the following output:
$cat testfile | tr a murz Amurz Z # converted output LINUX NETWORKS ARE BECOMING MORE AND MORE COMMON, BUT SCURITY IS OFTEN AN OVERLOOKED ISSUE. UNFORTUNATELY, IN TODAY'S ENVIRONMENT ALL NETWORKS ARE POTENTIAL HACKER TARGETS, FROM TP-SECRET MILITARY RESEARCH NETWORKS TO SMALL HOME LANS. LINUX NETWORK SECURTY FOCUSES ON SECURING LINUX IN A NETWORKED ENVIRONMENT, WHERE THE SECURITY OF THE ENTIRE NETWORK NEEDS TO BE CONSIDERED RATHER THAN JUST ISOLATED MACHINES. IT USES A MIX OF THEORY AND PRACTICL TECHNIQUES TO TEACH ADMINISTRATORS HOW TO INSTALL AND USE SECURITY APPLICATIONS, AS WELL AS HOW THE APPLCATIONS WORK AND WHY THEY ARE NECESARY. Case conversion can also be achieved through the: lower parameter. For example, use the following command:
Cat testfile | tr [: lower:] [: upper:] output result as follows:
$cat testfile | tr [: lower:] [: upper:] # converted output LINUX NETWORKS ARE BECOMING MORE AND MORE COMMON, BUT SCURITY IS OFTEN AN OVERLOOKED ISSUE. UNFORTUNATELY, IN TODAY'S ENVIRONMENT ALL NETWORKS ARE POTENTIAL HACKER TARGETS, FROM TP-SECRET MILITARY RESEARCH NETWORKS TO SMALL HOME LANS. LINUX NETWORK SECURTY FOCUSES ON SECURING LINUX IN A NETWORKED ENVIRONMENT, WHERE THE SECURITY OF THE ENTIRE NETWORK NEEDS TO BE CONSIDERED RATHER THAN JUST ISOLATED MACHINES. IT USES A MIX OF THEORY AND PRACTICL TECHNIQUES TO TEACH ADMINISTRATORS HOW TO INSTALL AND USE SECURITY APPLICATIONS, AS WELL AS HOW THE APPLCATIONS WORK AND WHY THEY ARE NECESARY. The above is all the contents of the article "how to use tr commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.