I have a number of HTML files that have the same section I want replaced:
<div id="main-content" class="span12">
<h1 id="404-page-not-found" style="text-align: center">404</h1>
<p style="text-align: center"><strong>Page not found</strong></p>
<p style="text-align: center"><a href=".">Home</a></p>
</div>
I want to replace this code with {{NAV}}
I feel like I can do something like:
bash script:
#!/bin/bash
find -name '*.html' | while read FILE; do
sed --in-place -f replace.sed "$FILE"
done
replace.sed:
<my code above here>{
r replacement
d
}
replacement:
{{NAV}}
But I cannot get the code I want gone and replaced correct in replace.sed.
Can anyone think of a better way or how to format my code properly?
sed, you either replace newlines with some other delimiter to replace at once, or write a sed program to match line by line. If you text is well formatted,awkmight be a better option.