//求均值
awk ‘{ sum = $1+sum ;count++ } END {print count, sum,sum/count}‘ aa.txt
awk ‘{max=($2>max?$2:max)} END {print max}‘ test.txt
分组求最大值
awk -F‘,‘ ‘{max[$1]=$2>max[$1]?$2:max[$1]} END {for (i in max) print i,max[i]}‘ t.txt
分组求和
awk -F‘,‘ ‘{sum[$1]=sum[$1]+$2} END {for (i in sum) print i,sum[i]}‘ t.txt