[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: search and replace code in php or html files



On Fri, 2006-05-05 at 13:16 -0400, H.S. wrote:
> The problem is to change a particular link in all the pages. I assume
> the webpages were made using a template. If I were to search and replace
> a particular string with a the new desired one, I would be done. Could
> somebody suggest the best way to use grep and sed to make these changes?
> The main problems are matching HTML code over a number of lines and
> replacing all of them. I am not averse to using perl either if I could
> get a starting point. All relevant suggestions are welcome. BTW, I have
> Debian Etch and Sid machines here on which I can work, if it matters.

find . -name "*.html" | xargs sed -i.bak -e
's/string_to_replace/replacement/g'

Does something like this work?  If your match pattern spans more than
one line than you'll need a more complex script.

Casey




Reply to: