- 论坛徽章:
- 0
|
本帖最后由 lightning 于 2011-11-10 10:24 编辑
原始数据:
2011:11:04 00:25:00|2011:11:04 00:30:00|0801|3501|notifyDeliveryReceipt|26|27|27|0||4349
2011:11:04 00:25:00|2011:11:04 00:30:00|2001|3501|notifyDeliveryReceipt|26|30|30|0||4579
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|0701|send|26|13|13|0||1920
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|1301|send|26|5|5|0||838
2011:11:04 00:25:00|2011:11:04 00:30:00|3101|3501|notifyDeliveryReceipt|26|5|5|0||785
2011:11:04 00:25:00|2011:11:04 00:30:00|2800|3501|notifyReception|26|3|3|0||496
2011:11:04 00:25:00|2011:11:04 00:30:00|2500|3501|notifyDeliveryReceipt|26|4|4|0||608
2011:11:04 00:25:00|2011:11:04 00:30:00|1900|3501|notifyDeliveryReceipt|26|49|49|0||7682
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|2300|send|26|9|9|0||1871
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|0600|send|26|2|2|0||388
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|1200|send|26|11|11|0||303
2011:11:04 00:25:00|2011:11:04 00:30:00|1400|3501|notifyReception|26|2|2|0||284
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|2800|DeliveryConfirm|26|3|3|0||3385
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|0801|send|26|19|19|0||4978
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|2001|send|26|22|22|0||1678
2011:11:04 00:25:00|2011:11:04 00:30:00|3501|0801|DeliveryConfirm|26|15|15|0||4275
结果类似: 得出方法为:以“|”为分割,在第5个域相同的情况下第7个和第8个域 分别求和,并且第8个域的和除以第7个域的和,算百分比
DeliveryConfirm|614828|99.54%
notifyReception|1119346|99.96%
notifyDeliveryReceipt|12957885|99.98%
send|14098578|98.85%
有以下脚本可以实现:
awk -F \| '$6==26{a[$5]+=$7}{c[$5]+=$8}END{m=asort(a,b);n=asort(c,d);{for(i=0;i<=m;i++) for(s in a) if(a==b){printf "%s|%s|%0.2f%\n",s,a,c/a*100}}}'
知道写的烂,希望高手帮忙优化优化语句。
谢谢了 |
评分
-
查看全部评分
|