0

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.

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
David
  • 11

1 Answers1

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>
tink
  • 6,765