Awk calculates the sum, average, maximum, and minimum values.

Source: Internet
Author: User
0. preparation and data files. for example, there is a data file with only one column (you can filter the column with only numbers by various means before ), for example, the operation response time Txt code 490898118923520212149427014651529369235635630272297612780916813551646188581897...

0. preparation and data files
For example, there is a data file with only one column (you can filter the column with only numbers by various means), such as the response time of the operation.
Txt code
490898
1189235
20212
1494270
146515
29369
23563
563027
22976
127809
16813
551646
18858
18977
 
1. sum
Cat data | awk '{sum + = $1} END {print "Sum =", sum }'
 
2. average calculation
Cat data | awk '{sum + = $1} END {print "Average =", sum/NR }'
 
3. calculate the maximum value
Cat data | awk 'In in {max = 0} {if ($1> max) max = $1 fi} END {print "Max =", max }'
 
4. calculate the minimum value (set an extra large value for the initial value of min)
Awk 'In in {min = 1999999} {if ($1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.