title: How can I insert a new line with sed that will allow a backslash in the entry
body: <p>I have a file that contains users.  The format of the file is as follows:</p>
  
  <pre><code>groupname:
  username \
  username2 \
  username3 \
  </code></pre>
  
  <p>and so on.</p>
  
  <p>I am automating a portion of adding users to this file.  I am currently using sed to complete this, but I am running into an issue.  Here is what I am using for my sed command</p>
  
  <pre><code>sed -i '/groupname/ a\'newuser' \ \' /path/to/file
  </code></pre>
  
  <p>My problem is that the above command will enter a space after the backslash, which, for unknown reasons causes the application that utilizes this file to cease working.</p>
  
  <p>I tried using the following with no positive results</p>
  
  <pre><code>sed -i '/groupname/ a\'newuser' \\' /path/to/file
  sed -i '/groupname/ a\'newuser \'\ /path/to/file
  sed -i '/groupname/ a\"newuser \"\ /path/to/file
  sed -i '/groupname/ a\'newuser' "\"\ /path/to/file
  </code></pre>
  
  <p>My next step I think might be ritual sacrifice, but, I would prefer not to have to go that route.</p>
  
  <p>I did try one thing with awk, but, I am less familiar with that.</p>
  
  <pre><code>awk '{print} /groupname/{print "newuser \"}' /path/to/file
  </code></pre>
  
  <p>That is met with an error message about an unterminated string starting at the " for "testing</p>
  
  <p>Any suggestions would be met with much enthusiasm until such a point ritual sacrifice might actually become a reality, then its just sad faces all around.</p>
  
  <p>Thanks in advance.</p>
  
  <p>[edit]</p>
  
  <p>For clarification, this command is being run from another server via ssh.  So the command that executes from server A is as follows:</p>
  
  <pre><code>ssh serverb "sudo sed -i '/groupname/ a\'newuser' \ \" /path/to/file
  </code></pre>
  
  <p>That command works to the extent it inserts the extra space after the "\" which I don't need.</p>