awk计算最大最小平均值

2018-01-31 by 秋刀鱼杂记


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}'






第七城市

栏目导航(关闭)