shell脚本统计IP归属地址

shell脚本统计IP归属地址

[root@localhost ~]# cat testipguishu.sh
#/bin/bash
#cd /data/iplog/$1/pv
#txt=$(ls -l|awk '{print $NF}'|sed '1d')
#for n in $txt
#do
#awk '{print $3}' $n |sort|uniq >/tmp/txt.${n}

#iptxt=$(ls -l /tmp/txt.*|awk '{print $NF}'|sed '1d')
#for n1 in $iptxt
#do
#cat $n1  >>/opt/newip.txt

#done
#done

#cat /opt/newip.txt|sort|uniq >>/opt/old.ip.txt

for ip in `cat /opt/test.ip.txt`; do
         #curl -s  --user-agent foobar https://ip.cn/index.php?ip=$ip|grep '所在地理位置'|awk -F '>' '{print $5,$9,$12}'|awk -F '[</]+' '{print $1,$2,$3}' >>/tmp/test11.txt
curl -s  --user-agent foobar https://ip.cn/index.php?ip=$ip|grep '所在地理位置'|awk -F '>' '{print $5,$9,$12}'|awk -F '[</]+' '{print $1,$2,$3}' |awk -F ' ' '{print $1,$3,$4,$NF}' >>/tmp/test11.txt
sleep 0.02
done

[root@localhost ~]# cat /opt/test.ip.txt

101.16.100.201
101.16.100.39
101.16.101.77
101.16.106.124
101.16.106.191
101.16.106.196
101.16.106.201
101.16.106.223
101.16.106.245

[root@localhost ~]# cat /tmp/test11.txt

101.16.100.201 河北省石家庄市 联通 China
101.16.100.39 河北省石家庄市 联通 China
101.16.101.77 河北省石家庄市 联通 China
101.16.106.124 河北省石家庄市 联通 China
101.16.106.223 河北省石家庄市 联通 China
101.16.106.245 河北省石家庄市 联通 China
101.16.106.61 河北省石家庄市 联通 China
101.16.112.102 河北省石家庄市 联通 China
101.16.112.136 河北省石家庄市 联通 China

转载于:https://blog.51cto.com/wujianwei/2165909

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值