shell分析切割日志,合并计算

1.日志格式如:
 
2013-03-05 13:17:45,657 [3612510923]   INFO -promotion.util.TaskFlowProcess - 任务正在执行id=260,sourceSize=2999,filterSize=2429, telSize=242
........

2.脚本
 
egrep -E 'id=[0-9]{1,4},sour' sms_log.txt|cut -c 80-| awk -F'[=,]' '{a[$2]++;s1[$2]+=$4;s2[$2]+=$6;s3[$2]+=$8;} END {for (i in a) print i,"soucre="s1[i],"filter="s2[i],"telsize="s3[i]}'

3.结果
  260 soucre=499840 filter=412181 telsize=412180
               261 soucre=499840 filter=412181 telsize=0

猜你喜欢

转载自tofhao.iteye.com/blog/1832341