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

While I've looked at:


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="" type="text/javascript"><\/script>');
    document.write('<script type="text/javascript">_qacct="p-XXXXXXXXXXXXXXXX-";quantserve();<\/script>');
<!-- End Quantcast tag -->

and replace it with:

<script type="text/javascript">
<script type="text/javascript" src="//"></script>
<img src="//" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/>

any suggestions?
LVL 20
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.

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 -pi {} \;

# to be improved in many ways ...

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.
for multi-line regex see m operator
  man perlre
virmaiorAuthor Commented:

I think these are the pieces i need.
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

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.