title: Replacing multiple lines in awk (or something)
body: <p>I have been trying to accomplish the following with SED but since SED is line based I am afraid I won't be able to do it:</p>
  
  <pre><code>sed -ri 's/(&lt;li&gt;\n\s+&lt;a href="#introduction")/&lt;li&gt;&lt;div class="toc-group"&gt;Topics&lt;\/div&gt;&lt;\/li&gt;\1/' index.php
  </code></pre>
  
  <p>This is supposed t change this:</p>
  
  <pre><code>          &lt;li&gt;
          &lt;a href="#introduction" class="toc-h1 toc-link" data-title="Introduction"&gt;Introduction&lt;/a&gt;
  </code></pre>
  
  <p>into this</p>
  
  <pre><code>&lt;li&gt;&lt;div class="toc-group"&gt;Topics&lt;\/div&gt;&lt;/li&gt;&lt;li&gt;
          &lt;a href="#introduction" class="toc-h1 toc-link" data-title="Introduction"&gt;Introduction&lt;/a&gt;
  </code></pre>
  
  <p>Basically a poor man's 'add a line in a specific place'. Unfortunately <code>\n</code> does not work as expected. I think AWK can do this but SED is the only tool I ever used and I know nothing about AWK so can please help me with a solution.</p>
  
  <p>FYI There is more than one item that needs to be added in different parts of the document so I need a solution that will allow me to choose a part of a code and then prepend in front of it. It will be utilised in a bash script for automation.</p>