Let’s say I have the following kind of file:
<?xml version="1.0" encoding="utf-8"?>
<preferences>
<section id="widgets">
<value id="version" xml:space="preserve">1</value>
</section>
<section id="wuid-b2a8e6b8-6619-714e-9cfe-466c27c90902">
<value id="path to widget data" xml:space="preserve">{Preferences}widgets/opera-adblock-1.3.4-1.oex</value>
</section>
<section id="wuid-0c5cfdb2-8e51-f149-a1e7-51d66240ed7a">
<value id="path to widget data" xml:space="preserve">{Preferences}widgets/flag-button-1.5.4-1.oex</value>
</section>
</preferences>
My mission is to add text right after the last occurrence of </section>.
Looking at these two it seems as if utilizing tac would be simpler but I don’t understand how to do that either: Using sed to append a string to the fourth occurrence of a pattern, http://www.unix.com/unix-dummies-questions-answers/46294-add-line-after-last-occurnace-pattern.html#post302149709
Thanks.
It’s easier to add things before the first occurrence of a string:
Results:
You can read more about how to insert a line before a string here. HTH.