title: Replacing filename placeholder with file contents in sed
body: <p>I'm trying to write a basic script to compile HTML file includes. 
  The premise goes like this:</p>
  
  <p>I have 3 files</p>
  
  <p><strong>test.html</strong></p>
  
  <pre><code>&lt;div&gt;
     @include include1.html
  
     &lt;div&gt;content&lt;/div&gt;
  
     @include include2.html
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>include1.html</strong></p>
  
  <pre><code>&lt;span&gt;
     banana
  &lt;/span&gt;
  </code></pre>
  
  <p><strong>include2.html</strong></p>
  
  <pre><code>&lt;span&gt;
     apple
  &lt;/span&gt;
  </code></pre>
  
  <p>My desired output would be:</p>
  
  <p><strong>output.html</strong></p>
  
  <pre><code>&lt;div&gt;
     &lt;span&gt;
        banana
     &lt;/span&gt;
  
     &lt;div&gt;content&lt;/div&gt;
  
     &lt;span&gt;
        apple
     &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I've tried the following:</p>
  
  <ol>
  <li><p><code>sed "s|@include \(.*)|$(cat \1)|" test.html &gt;output.html</code><br>
  This returns <code>cat: 1: No such file or directory</code></p></li>
  <li><p><code>sed "s|@include \(.*)|cat \1|" test.html &gt;output.html</code><br>
  This runs but gives: </p>
  
  <p><strong>output.html</strong></p>
  
  <pre><code>&lt;div&gt;
     cat include1.html
  
     &lt;div&gt;content&lt;/div&gt;
  
     cat include2.html
  &lt;/div&gt;
  </code></pre></li>
  </ol>
  
  <p>Any ideas on how to run <code>cat</code> inside <code>sed</code> using group substitution? Or perhaps another solution.</p>