title: Grep file with pattern and count individual pattern matches in a file without changing order
body: <p>i need to get total matches from input.txt in digits using the words in pattern.txt, it needs to match between tags too.</p>
  
  <p>this is the code im using and it works but output should be same sorting from input.txt and also remove the pattern from final output</p>
  
  <pre><code>grep -of pattern.txt input.txt | sort | uniq -c | awk '{print $2,$1}' &gt; output.txt
  </code></pre>
  
  <p>pattern.txt:</p>
  
  <pre><code>sistersdrama.com
  sisterssatellite.com
  orientalsisters.com
  </code></pre>
  
  <p>input.txt:</p>
  
  <pre><code>&lt;Model Make="www.sistersdrama.com" Displacement="1.6" HP="116" Year="2003"/&gt;
  &lt;Model Make="sistersdrama.com="3.5" HP="298" Year="2003"/&gt;
  &lt;Model Make="sistersdrama.com" Displacement="3.0" HP="200" Year="2011"/&gt;
  &lt;Model Make="sistersdrama.com" Displacement="2.0" HP="257" Year="2002"/&gt;
  &lt;Model Make="www.sisterssatellite.com" Displacement="2.5" HP="278" 
  Year="2002"/&gt;
  &lt;Model Make="www.sisterssatellite.com" Displacement="3.0" HP="224" 
  Year="2009"/&gt;
  &lt;Model Make="sisterssatellite.com" Displacement="1.8" HP="172" 
  Year="2007"/&gt;
  &lt;Model Make="sisterssatellite.com" Displacement="2.8" HP="186" 
  Year="2001"/&gt;
  &lt;Model Make="orientalsisters.com" Displacement="2.8" HP="179" 
  Year="2006"/&gt;
  &lt;Model Make="orientalsisters.com" Displacement="2.8" HP="207" 
  Year="2013"/&gt;
  &lt;Model Make="orientalsisters.com" Displacement="2.8" HP="246" 
  Year="2008"/&gt;
  &lt;Model Make="orientalsisters.com" Displacement="2.8" HP="244" 
  Year="1999"/&gt;
  &lt;Model Name="orientalsisters.com" Displacement="2.8" HP="244" 
  Year="1999"/&gt;
  </code></pre>
  
  <p>with the code used i get output.txt:</p>
  
  <pre><code>orientalsisters.com 4
  sistersdrama.com 3
  sisterssatellite.com 2
  </code></pre>
  
  <p>expected results with same order as pattern.txt, only digits and subtract 2:</p>
  
  <pre><code>1
  0
  2
  </code></pre>