title: Ruby grep, match and return
body: <p>Is there anyway to check if a value exist in a file without ALWAYS going through entire file ?</p>
  
  <p>Currently I used:</p>
  
  <pre><code>if open('file.txt').grep(/value/).length &gt; 0
    puts "match"
  else 
    puts "no match"
  end
  </code></pre>
  
  <p>But it's not efficient as I only want to know whether it exists or not. Really appreciate a solution with grep / others similar one-liner.</p>
  
  <p>Please note the "ALWAYS" before down-vote my question</p>