title: Inserting leading carriage return in sed append
body: <p>I am trying to insert some text after a string match using sed, and I'm having trouble getting a leading carriage return into the appended text.  I have ...</p>
  
  <pre><code>sed -i "/^#Comment to append text after/a \n[$username.conn]\nipAddress=$ipAddr\nportNumber=$portNum" file
  </code></pre>
  
  <p>And I would like a carriage return before that 3-line insert, so the output is ...</p>
  
  <pre><code>#Comment to append text after
  
  [$username.conn]
  ipAddress=xxx.xxx.xxx.xxx
  portNum=yyyy
  </code></pre>
  
  <p>But putting a <code>\n</code> in front of <code>[$username.conn]</code> just results in a leading n...</p>
  
  <pre><code>#Comment to append text after
  n[$username.conn]
  ipAddress=xxx.xxx.xxx.xxx
  portNum=yyyy
  </code></pre>
  
  <p>Any suggestions for how to do this?</p>