一、求和
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}'
四、求最小值(min的初始值設置一個超大數便可)
awk 'BEGIN {min = 1999999} {if ($1<min) min=$1 fi} END {print "Min=", min}'
五、求訪問次數的Top 10 Resource,能夠根據此進行優化
cat output/logs/cookie_logs/`date +%u`/cookie_log|grep -v '172.16'|grep -v '127.0.0.1' |awk -F' ' '{ if(index($1,"219.141.246")!=0) print $2; else print $1 } '|sort|uniq -c|sort -n |tail -n 10cookie
六、這個特麼有點意思。優化