In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "awk use case Analysis". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "awk usage case Analysis".
Awk is a powerful text analysis tool, compared with the search of grep and the editor of sed, awk is particularly powerful in analyzing data and generating reports. To put it simply, awk is to read the file line by line, and use the space as the default separator to slice each line, and then analyze the cut part.
Awk script awk script usually consists of the following three parts: BEGIN {statements before execution} END {statements to be executed after all lines are processed} {statements to be executed when each line is processed}
If you have the following table:
$cat score.txtMarry 2143 78 84 77Jack 2321 66 78 45Tom 2122 48 77 71Mike 2537 87 97 95Bob 2415 40 57 62
Awk script that counts the total amount of money everyone has, and the average situation:
#! / bin/awk-f# before running BEGIN {math = 0 english = 0 computer = 0 printf "NAME NO. MATH ENGLISH COMPUTER TOTAL\ n "printf" -\ n "} # running {math+=$3 english+=$4 computer+=$5 printf"%-6s%-6s% 4d% 8d% 8d% 8d\ n ", $1, $2, $3 END {printf "-\ n" printf "TOTAL:d% 8d% 8d\ n", math, english, computer printf "AVERAGE:.2f% 8.2f% 8.2f\ n", math/NR, english/NR, computer/NR}
Output result:
NAME NO. MATH ENGLISH COMPUTER TOTAL---Marry 2143 78 84 77 239Jack 2321 66 78 45 189Tom 2122 48 77 71 196Mike 2537 87 97 95 279Bob 2415 40 57 62 159 Murray-TOTAL: 319 393350AVERAGE: 63.8078.60 70.00 so far I believe that you have a deeper understanding of "awk use case analysis", you might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.