Re: [ILUG] Fw: Find&Replace Script

From: Lars Hecking (lhecking at domain nmrc.ucc.ie)
Date: Mon 23 Aug 1999 - 15:16:07 IST


> >now I forgot to include some additional info.
> >the script needs to exclude all index.html and menu.html files. It also
> >needs to appen a foot ssi comman to the bottom of the file. Which is
> >also part of the problem.
> >
> >so say for example the document looked like the following
> >
> >10 <html>
> >20 <head>
> >30 <title>title</title></head>
> >40 <body>
> >50 <table with="20" >
> >60 <include stuff>
> >70 <all text here blah blah blah>
> >80 <include stuff>
> >90 </body>
> >100 </html>
> >
> >not the top stff is allright till I get to the table on line 50 I need
> >to subsitute this whict my ssi <!--#exec cmd="/path/to/my/cmd"--> now
                ^^^^

 What exatcly is "this"? The whole table? I'd need to see a complete
 page then to advise a sensible strategy. Mulitilne replacements with
 sed can be done, but it doesn't look nice :)
 
> >the script has to realise that anything in the table tag needs to be
> >deleted and replace it with my ssi. i can leave the server specific stuu
> >alone as it does not show up. but also it has to go to the end of the
> >document just under the include (80) and put in <!--#exec
> >cmd="/path/to/other/cmd"--> say for the footer.

 sed -e 's,^</body>,<!--#exec cmd="/path/to/other/cmd"-->\
 &,'

> >If I say run find . -type f -name \*.html -exec cmd {} \; It will
> >append all files with that extension and stuff which can feck up all the
> >frames pages etc (I didn't design it).

 If this refers to the statement above (index.html and menu.html files
 must not be changed):

 find . \( -regex '.*\.html' -a ! -name index.html -a ! -name menu.html \) -print

 To be certain, I'd go with Kevin's sugegstion to create a file with a
 list first, which can be checked for correctness before the actual conversion
 is attempted.

> >Now I thought I had found a script of my dreams but the server turend
> >out to be a porn sever so all out of luck at the moment.
> >
> >So has anyone got any ideas? I am lost not as this level of scripting is
> >gone wayyyyyyy over my head. I would greatly appreciate any help you
> >could give me



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:29 GMT