title: Bash - grep to extract words ending with specified string; leave blank spaces where no match found
body: <p>Here's the input data:</p>
  
  <blockquote>
    <p>I/o live/o in/o New/B-geo-loc York/I-geo-loc<br>
    I/o live/o somewhere/o in/o space/o<br>
    I/o would/o love/o to/o live/o in France/B-geo-loc<br>
    This/o is/o my/o home/o<br>
    Sanfrancisco/B-geo-loc CA/I-geo-loc is/o a/o great/o place/o to/o live/o  </p>
  </blockquote>
  
  <p>The aim is to extract all the words that end with "<code>/B-geo-loc</code>" or "<code>/I-geo-loc</code>" and also leave a blank line where no match is found   </p>
  
  <p>Tried using the following regular expression in grep, but didn't get the desired output</p>
  
  <pre><code>grep -o '\w*/B-geo-loc\b \w*/I-geo-loc\b' sourcefile.txt &gt; targetfile.txt  
  </code></pre>
  
  <p>This is my regex output:</p>
  
  <blockquote>
    <p>New/B-geo-loc York/I-geo-loc<br>
    Sanfrancisco/B-geo-loc CA/I-geo-loc</p>
  </blockquote>
  
  <p>Instead of this desired ouput:</p>
  
  <blockquote>
    <p>New/B-geo-loc York/I-geo-loc<br>
    ---blank line---<br>
    France/B-geo-loc<br>
    ---blank line---<br>
    Sanfrancisco/B-geo-loc CA/I-geo-loc</p>
  </blockquote>
  
  <p>Thanks.</p>