title: Delete all Bash comments
body: <p>How can I match and delete all comments from the line? I can delete comments starting from new line, or the ones not in quotes using sed. But my script fails in the following examples</p>
  
  <pre><code>This one "# this is not a comment" # but this "is a comment"
  </code></pre>
  
  <p>Can sed handle this case? if yes what is the regex?</p>
  
  <p>Example:</p>
  
  <ul>
  <li><p>Input:</p>
  
  <pre><code>This one "# this is not a comment" # but this "is a comment" 
  </code></pre></li>
  <li><p>Output:</p>
  
  <pre><code>This one "# this is not a comment"
  </code></pre></li>
  </ul>