shell统计日志中ip出现次数

转自http://james-lover.iteye.com/blog/2105795

日志如下:

178.60.128.31 www.google.com.hk
193.192.250.158 www.google.com
210.242.125.35 adwords.google.com
210.242.125.35 accounts.google.com.hk
210.242.125.35 accounts.google.com
210.242.125.35 accounts.l.google.com
64.233.181.49 www.google.com
212.188.10.167 www.google.com
23.239.5.106 www.google.com
64.233.168.41 www.google.com
62.1.38.89 www.google.com
62.1.38.89 chrome.google.com
193.192.250.172 www.google.com
212.188.10.241 www.google.com
37.228.69.57 www.google.com
222.255.120.42 www.google.com
222.255.120.42 www.gstatic.com
212.188.10.167 www.googleapis.com
64.233.181.49 www.googleapis.com
64.233.181.49 fonts.googleapis.com
193.192.250.158 plus.google.com
193.192.250.158 talkgadget.google.com 
193.192.250.158 ssl.gstatic.com
193.192.250.158 images-pos-opensocial.googleusercontent.com
193.192.250.158 images1-focus-opensocial.googleusercontent.com
193.192.250.158 images2-focus-opensocial.googleusercontent.com
193.192.250.158 images3-focus-opensocial.googleusercontent.com
193.192.250.158 images4-focus-opensocial.googleusercontent.com
193.192.250.158 images5-focus-opensocial.googleusercontent.com
193.192.250.158 images6-focus-opensocial.googleusercontent.com
193.192.250.158 clients4.google.com
222.255.120.42 google.com
222.255.120.42 apis.google.com
222.255.120.42 clients1.google.com
193.192.250.158 clients2.google.com
193.192.250.158 clients3.google.com
193.192.250.158 clients5.google.com
64.233.181.49 maps.google.com
64.233.181.49 mts0.google.com
64.233.181.49 maps.gstatic.com

命令如下:

cat test.txt|awk '{print $1}'|sort|uniq -c

 结合sort和uniq命令

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值