您的位置:首页 > 运维架构 > Shell

使用shell统计ip的流量

2011-04-07 08:57 295 查看
[root@oracle shell_exmple]# cat test

10.1.1.1 10000089
10.1.1.2 99877008
10.1.1.3 488650
10.1.1.1 20789786
10.1.1.3 907675765
[root@oracle shell_exmple]# awk '{a[$1]}END{for(i in a)print a[i]}' test

[root@oracle shell_exmple]# awk '{a[$1]}END{for(i in a)print i}' test
10.1.1.3
10.1.1.1
10.1.1.2
[root@oracle shell_exmple]# awk '{a[$1]=a[$1]+$2} END{for(i in a)print a[i]/1024/1024"MB",i}' test | sort -nr
866.093MB 10.1.1.3
95.2501MB 10.1.1.2
29.3635MB 10.1.1.1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ip 职场 shell 休闲