LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1121|回复: 1

请各位帮忙,怎么处理这种文本?

[复制链接]
发表于 2008-7-13 14:05:12 | 显示全部楼层 |阅读模式
  1. # cat whois.file
  2. inetnum:      58.16.0.0 - 58.16.255.255
  3. netname:      CNCGROUP-GZ
  4. descr:        CNC Group Guizhou province network
  5. descr:        China Network Communications Group Corporation
  6. descr:        No.156,Fu-Xing-Men-Nei Street,
  7. descr:        Beijing 100031
  8. country:      CN
  9. admin-c:      CH455-AP
  10. tech-c:       CH455-AP
  11. remarks:      service provider
  12. mnt-by:       APNIC-HM
  13. mnt-lower:    MAINT-CNCGROUP-GZ
  14. mnt-routes:   MAINT-CNCGROUP-RR
  15. status:       ALLOCATED PORTABLE
  16. changed:      [email]hm-[email]changed@apnic.net[/email][/email] 20050125
  17. changed:      [email]hm-[email]changed@apnic.net[/email][/email] 20050218
  18. source:       APNIC

  19. inetnum:      58.14.0.0 - 58.15.255.255
  20. netname:      JNGDNET
  21. country:      CN
  22. descr:        Jinan Radio &TV Wellunited
  23. descr:        Digital Cable TV Co., Ltd
  24. descr:        3F Sanjianyinyuan Building,No.22 minsheng Road,
  25. descr:        Jinan, Shandong, P.R.China
  26. admin-c:      JX211-AP
  27. tech-c:       JX211-AP
  28. status:       ALLOCATED PORTABLE
  29. changed:      [email]shenzhi@cnnic.cn[/email] 20050623
  30. mnt-by:       MAINT-CNNIC-AP
  31. source:       APNIC

复制代码
  1. # cat isp.list
  2. CNCGROUP
  3. CHINANET
  4. CSTNET
  5. CERNET
  6. CMNET
  7. UNINET
  8. CRNET
  9. CIETNET
复制代码


我whois ip 58.16.0.0和58.14.0.0后,想知道他们属于哪个运营商

isp.list是八大骨干的名字

如果不在isp.list,我想优先取netname那栏的名字

比如我列的文本得到的结果应该是 58.16.0.0 属于CNCGROUP
                               58.14.0.0 属于JNGDNET

而不是CNCGROUP-GZ

我whois $ip | grep -f isp.list出来是CNCGROUP-GZ ,怎样能简单得转换成isp.list里面的名字?

可以有什么方法?? 先谢谢各位的帮忙:wink:
发表于 2008-7-14 17:55:48 | 显示全部楼层
whois 58.16.0.0| grep netname| sed 's/-.*//g'
为什么不这样呢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表