zoukankan      html  css  js  c++  java
  • Getting http address from text file by awk script

    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.

              

  • 相关阅读:
    栈的操作总结
    C语言复习大纲
    生理周期
    石子合并
    幸运数字
    最长&最短文本
    C++引用
    C++入门
    直角三角形
    思维的囚徒--读书摘记和自己的肤浅解读--2021.1
  • 原文地址:https://www.cnblogs.com/ordili/p/3993895.html
Copyright © 2011-2022 走看看