title: Sed: append after last occurrence
body: <p>Let's say I have the following kind of file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;preferences&gt;
    &lt;section id="widgets"&gt;
      &lt;value id="version" xml:space="preserve"&gt;1&lt;/value&gt;
    &lt;/section&gt;
    &lt;section id="wuid-b2a8e6b8-6619-714e-9cfe-466c27c90902"&gt;
      &lt;value id="path to widget data" xml:space="preserve"&gt;{Preferences}widgets/opera-adblock-1.3.4-1.oex&lt;/value&gt;
    &lt;/section&gt;
    &lt;section id="wuid-0c5cfdb2-8e51-f149-a1e7-51d66240ed7a"&gt;
      &lt;value id="path to widget data" xml:space="preserve"&gt;{Preferences}widgets/flag-button-1.5.4-1.oex&lt;/value&gt;
    &lt;/section&gt;
  &lt;/preferences&gt;
  </code></pre>
  
  <p>My mission is to add text right after the last occurrence of <code>&lt;/section&gt;</code>.</p>
  
  <p>Looking at these two it seems as if utilizing <code>tac</code> would be simpler but I don't understand how to do that either: <a href="https://stackoverflow.com/questions/9315959/using-sed-to-append-a-string-to-the-fourth-occurrence-of-a-pattern/9317095#9317095">Using sed to append a string to the fourth occurrence of a pattern</a>, <a href="http://www.unix.com/unix-dummies-questions-answers/46294-add-line-after-last-occurnace-pattern.html#post302149709" rel="noreferrer">http://www.unix.com/unix-dummies-questions-answers/46294-add-line-after-last-occurnace-pattern.html#post302149709</a></p>
  
  <p>Thanks.</p>