title: grep: Search for multiple strings in files recursively, to find source code
body: <p>I am fairly confident this can't be done with <code>grep</code>, unless there are some features that I don't know about. However I am hoping that if this is the case there might be some other Linux/Unix command line tool which will do the job I want.</p>
  <p>This is a frequent problem when working with source code, so I am pretty sure there must be an adequete solution.</p>
  <h3>Problem:</h3>
  <p>I am working with some C++ source code, and I want to be able to grep for objects in my code to find the files containing the relevant information.</p>
  <p>Here is a simple example:</p>
  <ul>
  <li>Search for all files which contain matches for &quot;MyClass&quot; in the namespace &quot;MYNAMESPACE&quot;.</li>
  <li>Assume that although MyClass and MYNAMESPACE appear to be likely to be unique strings, in general they might not be.</li>
  <li>In my case, the namespace &quot;MYNAMESPACE&quot; appears in hundreds of source files.</li>
  <li>The actual name of the class I am searching for is &quot;Parameter&quot;, which is such a generic word that it too appears in hundreds of files.</li>
  </ul>
  <p>Here is what I want a grep-like tool to do:</p>
  <ul>
  <li>Specify a list of words to search for</li>
  <li>Return the list of files found where ALL words in the list of search words are found in the same file</li>
  <li>Do this recursively to obtain all results in all files in a directory</li>
  </ul>
  <p>Surely there is a way to do this? This is essentially a filtering problem: Take all the files found (recursively) inside a directory, and apply a filter to them for each of the words in the input list. Files pass the filter if they contain at least one instance of each word.</p>