title: Efficient search of several strings in a text file
body: <p>I use <strong>egrep</strong> to look for exact matches of several strings in a very long file ( 1 million of lines):</p>
  
  <pre><code>egrep "\&lt;string1\&gt;|&lt;\string2\&gt;" my_file
  </code></pre>
  
  <p>But it takes too many time even to find just two strings. It seems that it look for every string along the total lines of the file even when it finds an occurrence. 
  Indeed, I know that the file contains just one occurence of each string. 
  Then I would like to know whow to force egrep to stop looking for a string once it finds an occurence of it and look for the next one of the list. Or if there is another way to do that efficiently.</p>
  
  <p>Thanks.</p>