0%

linux awk常用命令

awk统计接口耗时

1
2
3
4
5
6
7
8
9
grep 'handleShopBuy diff' run.log | wc -l

grep 'handleShopBuy diff' run.log | awk '$NF > 2000 && $NF <3000 {print $NF}'|wc -l

grep 'handleShopBuy diff' run.log |awk '{sum += $NF} END {printf "NR = %d,Average = %3.3f\n",NR,sum/NR}'

grep 'handleShopBuy diff' run.log |awk 'BEGIN{ max = 0} {if ($NF > max) max = $NF; fi} END{printf "Max = %.1f\n",max}'

grep 'handleShopBuy diff' run.log |awk 'BEGIN{min = 65535} {if ($NF < min) min = $NF;fi} END{printf "Min = %.1f\n",min}'

awk 去重

1
2
!a[$0]++
cat 11.txt |awk '!a[$1""$2]++{print}' //去重以第一列和第二列重复的行