awk 求和、最大、最小、平均值
cat data|awk '{sum+=$1} END {print "Sum = ", sum}'
2、求平均
cat data|awk '{sum+=$1} END {print "Average = ", sum/NR}'
3、求最大值
cat data|awk 'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}'
4、求最小值(min的初始值設定一個超大數即可)
awk 'BEGIN {min = 9999999} {if ($1<min) min=$1 fi} END {print "Min=", min}'