perl or bash question ["convert strings in a txt to html links"]
Vadkan Jozsef
jozsi.avadkan at gmail.com
Sat Feb 27 20:49:52 UTC 2010
you're the GOD. :D
I added some low-iq things to it ["extras"]:
ls *.txt | while read TXTNAME; do sed "s/á/a/g" $TXTNAME | sed "s/í/i/g"
| sed "s/ű/u/g" | sed "s/ő/o/g" | sed "s/ü/u/g" | sed "s/ö/o/g" | sed
"s/ú/u/g" | sed "s/ó/o/g" | sed "s/é/e/g" | sed "s/Á/A/g" | sed
"s/Í/I/g" | sed "s/Ű/U/g" | sed "s/Ő/O/g" | sed "s/Ü/U/g" | sed
"s/Ö/O/g" | sed "s/Ú/U/g" | sed "s/Ó/O/g" | sed "s/É/E/g" | sed -r
's,.*(http://[^ \"$]+).*,<a href=\"\1\">\1</a>,' | sed "s/$/<br>/g" >
$TXTNAME.html; done
thank you!!
On szo, 2010-02-27 at 14:59 -0500, Hal Burgiss wrote:
> 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