title: Bash. How to get multiline text between tags
body: <p>I'm trying to get text in my file between two tags. But if script finds opening tag and do not finds closing tag then it prints file from opening tag to the file's end. </p>
  
  <p>For example text is:</p>
  
  <pre><code>aaa
  TAG1
  some right text
  TAG2
  some text2
  TAG1
  some text3
  some text4
  </code></pre>
  
  <p>and script like this:</p>
  
  <pre><code>awk "/TAG1/,/TAG2/"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sed -n "/TAG1/,/TAG2/p"
  </code></pre>
  
  <p>than output will be:</p>
  
  <pre><code>some right text
  some text3
  some text4
  </code></pre>
  
  <p>but I need this:</p>
  
  <pre><code>some right text
  </code></pre>