title: Error while adding line to file using sed command
body: <p>I'm trying to add the following line to the beginning of file using sed command:</p>
  
  <p><strong>node /^$server$/ inherits default {</strong></p>
  
  <p>Command: <code>sed -i "1i node /^$server$/ inherits default {" "file.txt"</code></p>
  
  <p>When I run the command locally from the server it's working for me, but when I try to run it from bash script using this command:</p>
  
  <pre><code>sudo ssh serverName sed -i "1i node /^$server$/ inherits default {" "file.txt"
  </code></pre>
  
  <p>I got this error message:</p>
  
  <pre><code>"sed: -e expression #1, char 2: expected \ after a',c' or `i'"
  </code></pre>
  
  <p>I added \ after the 1i but this just adding the word "node" to the beginning of the file.</p>
  
  <p>The first line of the file need to be for example:</p>
  
  <p><strong>node /^serverName$/ inherits default {</strong></p>
  
  <p>I guess that I need to use regex in my command but I don't know how to do it.</p>
  
  <p>Please assist</p>