virmaior
asked on
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.protoco l != 'https:') {
document.write('<script src="http://edge.quantserve.com/quant.js" type="text/javascript"><\/ script>');
document.write('<script type="text/javascript">_qa cct="p-XXX XXXXXXXXXX XXX-";quan tserve();< \/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.c om/quant.j s"></scrip t>
<noscript>
<img src="//secure.quantserve.c om/pixel/p -XXXXXXXXX XX-.gif" style="display: none;" border="0" height="1" width="1" alt="Quantcast"/>
</noscript>
any suggestions?
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\.
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.protoco
document.write('<script src="http://edge.quantserve.com/quant.js" type="text/javascript"><\/
document.write('<script type="text/javascript">_qa
}
</script>
<!-- End Quantcast tag -->
and replace it with:
<script type="text/javascript">
_qoptions={
qacct:"p-XXXXXXXXXX-"
};
</script>
<script type="text/javascript" src="//secure.quantserve.c
<noscript>
<img src="//secure.quantserve.c
</noscript>
any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks!
I think these are the pieces i need.
I think these are the pieces i need.
ASKER
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.