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.

时间: 2024-10-15 03:41:00

Getting http address from text file by awk script的相关文章

Display certain line(s) from a text file in Linux.

Purpose: Display certain line or lines from a text file, such as : Display the 1000th line from file message.log or Display the lines between 1000 and 1020 from file message.log Solution: Using sed: sed -n '1000,1020p' message.log sed -n '1000,1020p;

create feature from text file

'''---------------------------------------------------------------------------------- Tool Name: CreateFeaturesFromTextFile Source Name: CreateFeaturesFromTextFile.py Version: ArcGIS 9.1 Author: Environmental Systems Research Institute Inc. Required

shell脚本执行时报"bad interpreter: Text file busy"的解决方法

在执行一个shell脚本时,遇到了"-bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy"错误提示,如下所示: [[email protected] bin]$ ./killSession.sh      -bash: ./killSession.sh: /bin/bash: bad interpreter: Text file busy 此时只需要在#!/bin/bash,加一空格#! /bin/bas

Writing Text File From A Tabular Block In Oracle Forms

The example given below for writing text file or CSV using Text_IO package from a tabular block in Oracle Forms. Suppose there is a tabular grid data block "Job_History" in your forms and you want to write a CSV on click of a button by reading w

SharePoint 2010: Export User Profile Properties to a Text File or Excel using PowerShell

导出到txt [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") [void][System.Reflection.Assembly]::LoadWithParti

【转】shell脚本执行时报"bad interpreter: Text file busy"的解决方法

1)问题现象: 在ubuntu下执行以下脚本( while_count),报错: -bash: ./while_count: /bin/bash: bad interpreter: Text file busy 2)问题原因: This happens because the script file is open for writing, possibly by a rogue process which has not terminated. 3)解决办法: Solution: Check

What is a text file and what is a binary file :)

If you are not coming from a programming background it might not yet be clear what is really a file? What is a binary file and what makes something a text file? 其实总归一句话:[Files that consist exclusively of ASCII characters are known as text ?les. All o

Save output to a text file from Mac terminal

  Simply with output redirection: system_profiler > file.txt Basically, this will take the output of system_profiler and save it to the file file.txt. There are technically two different output "streams", standard output, and standard error.

unity, read text file

using System.IO; //test read txt        //Resources.Load(...) loads an asset stored at path in a Resources folder.        //ref: http://docs.unity3d.com/Manual/class-TextAsset.html        //ref: http://forum.unity3d.com/threads/read-text-file-that-is