title: Replacing newline escape '\n' with an escaped newline escape '\\n' using sed
body: <p>I am trying to replace the literal term <code>\n</code> (not a newline, the literal) by the literal <code>\\n</code> using <code>sed</code>. I've tried this:</p>
  
  <pre><code>echo '"Refreshing \n\n\n state prior"' | sed 's/\\n/\\\n/g'
  </code></pre>
  
  <p>This "works" but I need it to output the literal characters <code>\\n</code>.  Right now I end up with something like this:</p>
  
  <pre><code>"Refreshing \
  \
  \
   state prior"
  </code></pre>
  
  <p>Is there a way for me to maintain the <code>\\n</code> in <code>sed</code> output?</p>