In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the use of awk in linux. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Awk introduction
Awk is a line processor. Compared with the advantages of screen processing, there is no memory overflow or slow processing when dealing with large files. It is usually used to format text information.
Awk processing: each row is processed in turn and then output.
Awk command form:
Awk [- F |-f |-v] 'BEGIN {} / / {command1; command2} END {}' file
Parameter description:
-F specifies the delimiter
-f call script
-v defines a variable
'' reference code block
BEGIN initialization code block, initializing the code before processing each line, mainly referencing global variables and setting the FS delimiter
/ / match the code block, which can be a string or a regular expression
{} command code block containing one or more commands
END ending code block, a code block that executes after each line is processed, mainly for final calculation or output ending summary information
Let's take a look at several apps:
Awk-F:'{print NF}'/ etc/passwd / / how many fields are there in each line of the output file? awk-F:'{print $1rec. 2 print NR,$1,$2,$3. 3 print NR,$1,$2,$3 5}'/ etc/passwd / / output the first five fields, OFS='\ t / etc/passwd / / output the first five fields and use tabs to separate the first five fields. 5} 'OFS='\ t' / etc/passwd / / Tab separates the first five fields of the output And print the line number above is the use of awk in linux shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are 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.