title: About 'grep -f': match pattern with file
body: <p>I am using the <code>grep -f</code> function to extract lines from a file which match a particular pattern. Let's say my pattern file is <code>pattern.txt</code>, as follows.</p>
  
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  
  <p>And the file against which I am matching this pattern is <code>file.txt</code>,</p>
  
  <pre><code>1::anv
  2::tyr
  3::yui
  4::fng
  5::gdg
  6::ere
  7::rer
  8::3rr
  9::gty
  </code></pre>
  
  <p>Now when I do a grep -f pattern.txt file.txt, I am getting this -> </p>
  
  <pre><code>1::anv
  2::tyr
  3::yui
  4::fng
  5::gdg
  8::3rr
  </code></pre>
  
  <p>The last line in the output above, is causing my problem. How do I modify this grep command so as to get the output (showing correct correspondences) as follows?</p>
  
  <pre><code>1::anv
  2::tyr
  3::yui
  4::fng
  5::gdg
  </code></pre>