title: How would I replace a single quote (') with a backslash then single quote (\') using sed?
body: <p>How would I replace a single quote (') with a backslash then single quote (\') using sed?</p>
  
  <pre><code>sed s/\'/\\\'/
  </code></pre>
  
  <p>won't work because you never get to write the literal .</p>
  
  <pre><code>sed ":a;N;s/\'/\\'/g" &lt;file1 &gt;file2
  </code></pre>
  
  <p>won't work because the backslash will no longer escape the quote, it get's treated like a regex quote.</p>