In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "Shell script regular expressions in awk, sort, uniq how to use", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Shell script regular expressions in awk, sort, uniq how to use" this article.
Awk tool
In the Linux/UNIX system, awk is a powerful editing tool, which reads the input text line by line, searches according to the specified matching pattern, formats and outputs or filters the content that meets the criteria, and can achieve quite complex text operations without interaction. It is widely used in Shell scripts to complete a variety of automatic configuration tasks.
Common uses of 1.awk:
Typically, the command format used by awk is as follows, where single quotation marks and curly braces "{}" are used to set the processing action on the data. Awk can process the target file directly or through the "- f" read script.
Demo1:
Find out the user name and other columns of / etc/passwd and execute the following command
[root@localhost ~] # awk-F':'{print $1 1daemon 4} / etc/passwdroot 0 0bin 1 1daemon 22 awk / the following omitted multiple lines contains several special built-in variables (available directly) as follows: FS: specifies the field delimiter for each line of text, which defaults to spaces or tabs. NF: the number of fields in the rows currently being processed. NR: the line number (ordinal) of the currently processed row. $0: the entire line content of the currently processed row. $n: the nth field (nth column) of the currently processed row. FILENAME: the name of the file being processed. RS: data records are separated. The default is\ n, that is, one record per behavior.
Output text by line:
[root@localhost ~] # awk 'NR==1,NR==3 {print}' / etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologin [root@localhost ~] # awk-F ":" 'NR==1,NR==3 {print $1 awk 3}' / etc/passwdroot 0bin 1daemon 2 [root@localhost ~] # awk-F ":'(NR > = 1) & & (NR)
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.