title: sed/awk - print text between patterns spanned across multiple lines
body: <p>I am new to scripting and was trying to learn how to extract any text that exists between two different patterns. However, I am still not able to figure out how to extract text between two patterns in the following scenario:</p>
  
  <p>If I have my <strong>input file</strong> reading:</p>
  
  <pre><code>Hi I would like
  to print text
  between these 
  patterns
  </code></pre>
  
  <p>and my expected <strong>output</strong> is like:</p>
  
  <pre><code>I would like
  to print text
  between these 
  </code></pre>
  
  <p>i.e. my first search pattern is "Hi' and skip this pattern, but print everything that exists in the same line following that matched pattern. My second search pattern is "patterns" and I would like to completely avoid printing this line or any lines beyond that.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>sed -n '/Hi/,/patterns/p' test.txt 
  </code></pre>
  
  <p>[output]</p>
  
  <pre><code>Hi I would like
  to print text
  between these 
  patterns 
  </code></pre>
  
  <p>Next, I tried:</p>
  
  <pre><code>`awk ' /'"Hi"'/ {flag=1;next} /'"pattern"'/{flag=0} flag { print }'` test.txt 
  </code></pre>
  
  <p>[output]</p>
  
  <pre><code>to print text
  between these
  </code></pre>
  
  <p>Can someone help me out in identifying how to achieve this?
  Thanks in advance</p>