0

This question already has an answer here:

I have about 450 html files I need to edit. I have the directory they all are in, so that narrows things down from the perspective of searching.

What needs to be changed is a bit of known text, some unknown text, then some known text again. This would be an example:

Line 1

<div class="I know this"> Some random text here

Line 2:

More text</div (I know this)>

The above segments needs to be removed.

Below would need to be replaced. It would span multiple lines, but will be consistently the same all across.

<div class="oldFooter">Old Footer</div>

With:

<div class="newFooter">New Footer text</div>

I've found that I need to use SED, but I am not sure what exactly to put in.

marked as duplicate by Sparhawk, Rui F Ribeiro linux Dec 12 '18 at 22:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Minimal sample:

cat kyo
<div class="I know this"> Some random text here
More text</div (I know this)>
<div class="oldFooter">Old Footer</div>

Effect:

sed -r '/"I know this/,/\(I know this/d;s/oldFooter/newFooter/;s/>Old Footer</>New Footer text</' kyo
<div class="newFooter">New Footer text</div>

Not the answer you're looking for? Browse other questions tagged or ask your own question.