In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
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
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.