首页 > 其他 > 详细

Getting http address from text file by awk script

时间:2014-09-26 00:34:29      阅读:620      评论:0      收藏:0      [点我收藏+]

Today , I writed a awk script,it can get http address. The http address only contains number, alphabet,backslash and point. My awk script is following:

 

#! /bin/awk -f

{

  httpIndex=index($0,"http://")

      if ( httpIndex > 0 )

     {

        match($0,/http:\/\/[[:alnum:]\.\//)

          httpstr=substr($0,RSTART,RSTART + RLENGTH -1 )

     match(httpstr,/http:/\/\/[[:alnum:]\.\/]/)        // line 8

    httpstr=substr(httpstr,RSTART,RSTRAT + RLENGTH -1 ) // line 9

            print httpstr

     }

}

 

I test this script by 1 000 line texts, I found I need add line 8 and line 9 code, otherwise some http address always behand by some special character ,such as space.

          

 

Getting http address from text file by awk script

原文:http://www.cnblogs.com/ordili/p/3993895.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!