[Gllug] sed question: hyperlinking URLs

J F jnns at linuxmail.org
Wed Jan 24 15:47:01 UTC 2007


I'm trying to write a sed command to pick out URLs in a file and turn them into an HTML hyperlink. I've come with this thus far:

sed -e "s/\(www\.[,\=\/\%\&\+\#\?0-9_a-z\.A-Z-]\+\)/\x3Ca href=\"http\x3A\/\/\1\"\x3E\1\x3C\/a\x3E/g" file.txt

(\x3C is a '<' character; \x3E is a '>' character; \x3A is a colon.)

The trouble is, the input text contains URLs at the end of sentences and the expression picks up the full stop ending the sentence.

For example, a sentence such as 

  Visit www.google.com. 

is changed to:

  Visit <a href="http://www.google.com.">www.google.com.</a>

what I want is:

  Visit <a href="http://www.google.com">www.google.com</a>.
 
Any ideas?

TIA

=
Paladin POS Software for Retail Stores
Windows POS software for retail and hardware stores.
http://a8-asy.a8ww.net/a8-ads/adftrclick?redirectid=c167c119648afa4722a4ac05b137ecec


-- 
Powered by Outblaze
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list