cat test.txt
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
cat test.txt |awk '{sum += $1} END {printf "NR = %d,Average = %3.3f\n",NR,sum/NR}'
NR = 9,Average = 0.500
cat test.txt |awk 'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}'
Max= 0.9
cat test.txt |awk 'BEGIN {min = 6553565} {if ($1<min) min=$1 fi} END {print "Min=", min}'
Min= 0.1
网友评论