title: Print lines between two regex using sed
body: <p>I have a text file which contains multiple sections and I want to print one of those sections.</p>
  
  <p>Part of the file looks like</p>
  
  <pre><code>3. line 3
  4. line 4
  
  ## Screenshots ##
  
  1. line 1
  2. line 2
  3. line 3
  4. line 4
  
  ## Changelog ##
  
  3. line 3
  4. line 4
  </code></pre>
  
  <p>From this I want to retrieve all lines between <code>## Screenshots ##</code> and the starting of the next section. Here the next section is <code>## Changelog ##</code>, but it could be anything. So the only thing which we can depend on is that it will start with <code>##</code>.</p>
  
  <p>From <a href="https://stackoverflow.com/a/8967705/24949">another thread</a>, I found the following code</p>
  
  <pre><code>sed -e "H;/${pattern}/h" -e '$g;$!d' $file
  </code></pre>
  
  <p>which I modified to</p>
  
  <pre><code>sed -e "H;/## Screenshots ##/h" -e '$g;$!d' readme.md
  </code></pre>
  
  <p>Now, it retrieves all lines starting from <code>## Screenshots ##</code>, but it prints all lines till the end of the file.</p>
  
  <p>I then piped it to another <code>sed</code> like</p>
  
  <pre><code>sed -e "H;/## Screenshots ##/h" -e '$g;$!d' readme.md | sed "/^##/q" 
  </code></pre>
  
  <p>But now it prints only</p>
  
  <pre><code>## Screenshots ##
  </code></pre>
  
  <p>Is there anyway I can print all lines in the screenshots section?</p>