How do I perform a multi-file, multi-line, multi-directory find/replace in linux?

While I've looked at:

http://rushi.wordpress.com/2008/08/05/find-replace-across-multiple-files-in-linux/

and

http://www.liamdelahunty.com/tips/linux_search_and_replace_multiple_files.php

when I try to use them, neither accomplishes what I am looking for.  basically I want to do site-wide replace of a multiple line javascript by using a command line find/replace in linux.


in terms of modifying perl -pi -w -e 's/\.\.\/includes\/style\.css/admin\.css/g;' *.php

I am not sure how to change it to handle (a) multiple lines and (b) multiple directories.

here's what I want to find:

<!-- Start Quantcast tag -->
<script type="text/javascript">
if(window.location.protocol != 'https:') {
    document.write('<script src="http://edge.quantserve.com/quant.js" type="text/javascript"><\/script>');
    document.write('<script type="text/javascript">_qacct="p-XXXXXXXXXXXXXXXX-";quantserve();<\/script>');
}
</script>
<!-- End Quantcast tag -->

and replace it with:

<script type="text/javascript">
_qoptions={
qacct:"p-XXXXXXXXXX-"
};
</script>
<script type="text/javascript" src="//secure.quantserve.com/quant.js"></script>
<noscript>
<img src="//secure.quantserve.com/pixel/p-XXXXXXXXXXX-.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/>
</noscript>

any suggestions?
LVL 20
virmaiorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
assuming you have a perl script which makes your changes for one file:

find /path/to/dir/where/to/start/ -type f -name \*.php -exec your-script.pl -pi {} \;

# to be improved in many ways ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
virmaiorAuthor Commented:
definitely a step in the right direction...

I don't have the multi-line regex as of yet, so i'm going to leave it open for a day or two to see if anyone appears with one.

if not, i'll give you the points and ask that in the perl area.
0
ahoffmannCommented:
for multi-line regex see m operator
  man perlre
0
virmaiorAuthor Commented:
thanks!

I think these are the pieces i need.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.