0

I need to add </span> before every following <span.* aka. the "endig tag" for all rows in the "page".

example row:

<span class="bold">│<span class="f9"> 1,245,732 <span class="f0"><span class="bold">│<span class="f9"> —             <span class="f0">

Fiddled with sed, but just can't get it working...

Please help for I know this is trivial for some/most of you.

0

For a given line on the format that you show, the following would add </span> before each <span , and then remove the one that was added at the very start and add one at the very end.

sed -e 's,<span ,</span>&,g' -e 's,^</span>,,' -e 's,$,</span>,'

I'm using commas as delimiters in the s commands as the strings that we use contains /.

| improve this answer | |
  • THANKS! , I ended up with: sed -e 's,<span ,</span>&,g' -e 's,^</span>,,' -e 's,(<span.*)$,\1</span>,' for Your command adds </span> at the end of EVERY line and I have other kind of lines as well. – Antti Lagus Apr 6 at 5:57
  • sed -e 's,<span ,</span>&,g' -e 's,^</span>,,' -e 's,\(<span.*\)$,\1</span>,' of course.. :) – Antti Lagus Apr 6 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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