I'm trying to use the terminal to replace some html code in a file.
This is the command I'm using
perl -pi -w -e 's/find/replace/g;' /Volumes/Abc.html
I'm trying to replace
<body>
with
<body>
<div style="text-align: center;page-break-after:always;padding-top:0%;">
<img src="images/image-001.jpg" id="illustration" alt="illustration" />
<div id="caption" style="text-align:right;font-style:italic;"></div>
</div>
so I've been trying this, but I can't figure out how to escape all the characters. Can you help?
perl -pi -w -e 's/<body>/<body>
<div style="text-align: center;page-break-after:always;padding-top:0%;">
<img src="images/image-001.jpg" id="illustration" alt="illustration" />
<div id="caption" style="text-align:right;font-style:italic;"></div>
</div>
/g;' /Volumes/Abc.html
Thanks!
Use another separator, like {}
.
perl -pi -w -e 's{<body>}{...}g' /Volumes/Abc.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With