码迷,mamicode.com
首页 > 其他好文 > 详细

Getting http address from text file by awk script

时间:2014-09-26 02:49:58      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:http   ar   sp   art   on   c   ad   line   r   

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   ar   sp   art   on   c   ad   line   r   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!