awk
求和
cat data|awk ‘{sum+=$1} END {print "Sum = ", sum}‘
平均值
cat data|awk ‘{sum+=$1} END {print "Average = ", sum/NR}‘
最大值
cat data|awk ‘BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Max=", max}‘
最小值
awk ‘BEGIN {min = 1999999} {if ($1<min) min=$1 fi} END {print "Min=", min}‘
其中min设置为一个差大数字
grep
sed
时间: 2024-10-07 23:04:46