I've got a bunch of html files that I need to replace the following text:
<div id="header">
plus all info between
<!-- end #header -->
with
<?php include ("header.php"); ?>
I thought I could run something like this but it isn't matching the text:
perl -p -i.bak -e 's/<div id="header">.*<!\-\- end #header \-\->/<\?php include \("header\.php"\); \?>/g' *.html
or
perl -p -i.bak -e 's/<div id="header">[\S\s\n]*<!\-\- end \#header \-\->/<\?php include \("header\.php"\); \?>/img' *.html
I don't know if it's not searching across multiple lines and I need a parameter or I'm not escaping characters right. Any help would be appreciated.
I would like to batch run this in a directory and change all the content within each file where appropriate.
EDIT: looking for a single command line version, not using multiple pl files if possible.