title: Shell Script To Search Paragraphs for a given pattern
body: <p>I need help with a shell-script which can search an INPUT_FILE for PARAGRAPHS containing a MATCHING PATTERN (In ANY Line of the PARAGRAPH) &amp; produce 2 Output Files: </p>
  
  <p>OUTPUT_FILE_1:: File containing ONLY PARAGRAPHS which do NOT contain the MATCHING PATTERN in any of the Lines</p>
  
  <p>OUTPUT_FILE_2:: File containing ONLY PARAGRAPHS which contains the MATCHING PATTERN in any of the Lines</p>
  
  <p>INPUTS FOR SHELL SCRIPT::
  1. INPUT_FILE
  2. MATCH_KEY [ Here, MATCH_KEY="<strong>pattern match</strong>" ]</p>
  
  <p><strong>ASSUMPTION:</strong></p>
  
  <pre><code>All PARAGRAPHS are separated by a BLANK LINE
  </code></pre>
  
  <p><strong>// INPUT_FILE</strong></p>
  
  <pre><code>first paragraph first line
  first paragraph second line
  first paragraph third line
  
  second paragraph first line
  second paragraph pattern match second line
  second paragraph third line
  
  third paragraph first line
  third paragraph second line
  third paragraph third line
  
  fourth paragraph first line
  fourth paragraph second line
  fourth paragraph pattern match third line
  </code></pre>
  
  <p><strong>2 Output Files:</strong></p>
  
  <p><strong>// OUTPUT_FILE_1:: contains ONLY Paragraphs WITH MATCHING PATTERN</strong></p>
  
  <pre><code>second paragraph first line
  second paragraph pattern match second line
  second paragraph third line
  
  fourth paragraph first line
  fourth paragraph second line
  fourth paragraph pattern match third line
  </code></pre>
  
  <p><strong>// OUTPUT_FILE_2:: contains ONLY Paragraphs WITHOUT MATCHING PATTERN</strong></p>
  
  <pre><code>first paragraph first line
  first paragraph second line
  first paragraph third line
  
  third paragraph first line
  third paragraph second line
  third paragraph third line
  </code></pre>
  
  <p>Thanks</p>