On Sun, 31 Jul 2005 21:50:15 +0100 THUFIR HAWAT wrote: > On 7/31/05, Thomas Springer <th.springer@xxxxxxx> wrote: > ... > > Try this: > > > > $ sed 's|^http://\(.*/\)\(.*\)|<a href="\1\2">\1</a>|g; s|href="| > > href="http://|g' /input/file/with/links > /output/file/with/ > > clicklinks > > > > > > It's minimal changed from the first example, which didn't things > > well when i tried it out with your uri. > > > > > > Thomas > ... > > Sorry that I didn't notice that sed was using input and output files, > should've seen that. > > I made a dummy with just one link to test the sed command. The link > is entirely on one line, where as if I were to paste it here then it > would wrap, I'm not sure if that's relevant. > > Here's the link in dumm.txt, wrapped: > > <http://ipac3.vpl.ca/ipac20/ipac.jsp?uri=full=3100001~!1150206~!25&ri=4&aspect=basic_search$> > > > [thufir@arrakis click]$ date > Sun Jul 31 21:26:23 IST 2005 > [thufir@arrakis click]$ pwd > /home/thufir/click > [thufir@arrakis click]$ ll > total 36 > -rw-rw-r-- 1 thufir thufir 0 Jul 31 21:26 clicklist.txt > -rw-rw-r-- 1 thufir thufir 95 Jul 31 21:26 dummy.txt > -rw-rw-r-- 1 thufir thufir 5366 Jul 31 08:37 linklist.txt > -rw-rw-r-- 1 thufir thufir 5366 Jul 31 15:38 linklist.txt.backup > [thufir@arrakis click]$ cat dummy.txt > http://ipac3.vpl.ca/ipac20/ipac.jsp?uri=full=3100001~!1150206~!25&ri=4&aspect=basic_search$ > > > [thufir@arrakis click]$ sed 's|^http://\(.*/\)\(.*\)|<a > href="\1\2">\1</a>|g; s|href="| > href="http://|g' dummy.txt > clicklist.txt > sed: -e expression #1, char 58: unterminated `s' command > [thufir@arrakis click]$ > > > > I opened "dummy.txt" from openoffice and the link wasn't clickable, > but I do notice that if I were to e-mail these to myself that they > become clickable from gmail. Still, I'd like to get the sed command > working, partly out of curiousity. > > > Thanks, > > Thufir > It goes like this, $ sed 's|^http://\(.*/\)\(.*\)|<a href="\1\2">\1</a>|g; > s|href="| href="http://|g' dummy.txt > clicklist.txt $ echo $? 0 $ cat clicklist.txt <a href="http://ipac3.vpl.ca/ipac20/ipac.js..">ipac3.vpl.ca/ipac20/</a> Sorry,I can't see why it doesn't work for you. Try again, or use the file which comes with this message. * Save, * make it executable, then * ./clinks.sh inputfile > outputfile Thomas
Attachment:
clinks.sh
Description: Bourne shell script