求和
[root@114 ~]# cat data.log
1
2
3
6
7
[root@114 ~]# awk ‘{a+=$1}END{print a}’ data.log
19
平均值
[root@114 ~]# awk ‘{a+=$1}END{print a/NR}’ data.log
3.8
最大值
awk ‘BEGIN{max=-1111111111}{if($2>max)max=$2}END{print max}’ log.data
7
最小值
[root@112 ~]# awk ‘BEGIN{max=1111111111}{if($2<max)max=$2}END{print max}’ log.data
5
awk ‘{print $2}’ log.data |python -c “import sys;nums=[int(i) for i in sys.stdin.readlines()];print max(nums) “
awk ‘{print $2}’ log.data |python -c “import sys;nums=[int(i) for i in sys.stdin.readlines()];print min(nums) ”
awk ‘{print $2}’ log.data |python -c “import sys;nums=[int(i) for i in sys.stdin.readlines()];print sum(nums)/len(nums) “
awk ‘{print $2}’ log.data |python -c “import sys;nums=[int(i) for i in sys.stdin.readlines()];print sum(nums)”
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/tech/opensource/195886.html