title: loop matched string in a text file
body: <p>How can i loop by string "BUILD #" and only print the lines which has following string "http://" using bash script?
   or how can we have everything in between to strings "BUILD "
  input.txt</p>
  
  <pre><code>BUILD #1
  http://a
  b
  http://c
  
  BUILD #2
  http://d
  http://c
  http://g
  
  
  BUILD #3
  g
  http://h
  http://f
  e
  http://t
  </code></pre>
  
  <p>desired output</p>
  
  <p><sup><strong>Editor's note</strong>: As evidenced by what answer was accepted, the question turned out <em>not</em> to be about producing <em>filtered</em> output, but about selectively <em>processing</em> lines in a manner that is aware of the enclosing <em>build context</em>,
   as implied by the respective preceding <code>BUILD #&lt;n&gt;</code> line.</sup></p>
  
  <pre><code>BUILD #1 (loop)
  http://a
  http://c
  add another loop to do something with http://
  
  BUILD #2 (loop)
  http://d
  http://c
  http://g
  add another loop to do something with http://
  
  BUILD #3 (loop)
  http://h
  http://f
  http://t
  add another loop to do something with http://
  </code></pre>
  
  <hr>
  
  <p>input.txt has list of Merge request.</p>
  
  <pre><code>BUILD #1
  take the link (integrate)
  take the link (integrate)
  kick of a build (build command)
  BUILD #2 
  take the link (integrate)
  take the link (integrate)
  take the link (integrate)
  kick of a build (build command)
  and so on 
  </code></pre>