title: How to insert new line using sed and variables
body: <p>I am trying to extract a last entry with keyword "purchased" and append to a next line after a specific string(replacing the already existing line. As an example</p>
  
  <p>contents of order.log</p>
  
  <pre><code>discounted
  order56
  </code></pre>
  
  <p>run script</p>
  
  <pre><code>disc=$(cat status.log | grep discounted | tail -1)
  sed '/discounted/a $disc' order.log
  </code></pre>
  
  <p>if the output of disc is order59 then order.log should look like this</p>
  
  <pre><code>discounted
  order59
  </code></pre>
  
  <p>bot for some reason my sed command doesn't work</p>
  
  <pre><code>sed '/discounted/a $disc' order.log
  </code></pre>