The title speaks for itself really. I only want to know if it exists, not where it is. Is there a one liner to achieve this?
Well it seems eed3si9n has the one liner down, here's the longer solution:
f = File.new("file.txt") text = f.read if text =~ /string/ then #relevant code end