Here is the input I have and the output I want:
Input:
<hr />
(newline)
( carriage return)
(tabs, spaces)<div id="sidebar">
Output:
</div>
<hr />
(newline)
( carriage return)
(tabs, spaces)<div id="sidebar">
This doesn’t seem to match it:
sed -i 's/<hr \/>[[:space:]]*<div id="sidebar">/<\/div><hr \/><div id="sidebar">/g' file.txt
Hrm?
I don’t think you can really do this with
sed, because I don’t know of any way to convince it to operate on multiple lines at once. It really wants to operate on one line at a time. You can do it reasonably easily with Perl, though: