perl or bash question ["convert strings in a txt to html links"]

Hal Burgiss hal at burgiss.net
Sat Feb 27 19:59:37 UTC 2010


On Sat, Feb 27, 2010 at 06:12:05PM +0100, Vadkan Jozsef wrote:
> Turning:
> 
> http://website.org
> http://www.website.org
> 
> to this:
> 
> <a href=http://website.org>http://website.org</a>
> <a href=http://www.website.org>http://www.website.org</a>
> 
> The solution would be:
> 
> sed 'SOMEMAGIC' file.txt > file.html
> or
> perl 'SOMEBIGMAGIC' file.txt > file.html

cat $file | sed -r 's,.*(http://[^ \"$]+).*,<a href=\"\1\">\1</a>,' > file.html

Different, but comparable syntax. 

-- 
Hal




More information about the ubuntu-users mailing list