awk计算最大最小平均值

awk计算最小值

cat stream.txt | grep Triad | awk ‘NR==1{min = $2;next} {if ($2<=min) min=$2 fi} END {print “min=”, min}’

awk计算最大值

cat stream.txt | grep Triad | awk ‘NR==1 {max =$2 ;next} {if ($2>max) max=$2 fi} END {print “max=”, max}’

awk求和

cat iperf.txt | grep sender | awk ‘{sum+=$7} END {print sum}’

awk计算平均值

cat iperf.txt | grep sender | awk ‘{sum+=$7} END {print sum/NR}’

    原文作者:秋刀鱼杂记
    原文地址: https://www.jianshu.com/p/dc3da9fdeb0d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞