title: Using sed to delete all lines between two matching patterns
body: <p>I have a file something like:</p>
  
  <pre><code># ID 1
  blah blah
  blah blah
  $ description 1
  blah blah
  # ID 2
  blah
  $ description 2
  blah blah
  blah blah
  </code></pre>
  
  <p>How can I use a sed command to delete all lines between the <code>#</code> and <code>$</code> line? So the result will become:</p>
  
  <pre><code># ID 1
  $ description 1
  blah blah
  # ID 2
  $ description 2
  blah blah
  blah blah
  </code></pre>
  
  <p>Can you please kindly give an explanation as well?</p>