If you want to search a very large number of files or very large files, then performing the search (with grep, perhaps run in a pipeline together with find or locate) may be impractically slow. In that case, you may want to look at a package called glimpse. The way it works is that it builds an index of all content of all files, which then speeds up searching massively. There is a nice research paper by Udi Manber about that.