title: How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?
body: <p>I have a file like the following and I would like to print the lines between two given patterns <code>PAT1</code> and <code>PAT2</code>.</p>
  
  <pre class="lang-none prettyprint-override"><code>1
  2
  PAT1
  3    - first block
  4
  PAT2
  5
  6
  PAT1
  7    - second block
  PAT2
  8
  9
  PAT1
  10    - third block
  </code></pre>
  
  <p>I have read <a href="https://stackoverflow.com/q/17988756/1983854">How to select lines between two marker patterns which may occur multiple times with awk/sed</a> but I am curious to see all the possible combinations of this, either including or excluding the pattern.</p>
  
  <p>How can I print all lines between two patterns?</p>