title: How to use grep with large (millions) number of files to search for string and get result in few minutes
body: <p>This question is related to
  <a href="https://stackoverflow.com/questions/5200591/how-to-use-grep-efficiently">How to use grep efficiently?</a></p>
  
  <p>I am trying to search for a "string" in a folder which has 8-10 million small (~2-3kb) plain text files. I need to know all the files which has "string".</p>
  
  <p>At first I used this</p>
  
  <pre><code>grep "string"
  </code></pre>
  
  <p>That was super slow.</p>
  
  <p>Then I tried</p>
  
  <pre><code>grep * "string" {} \; -print
  </code></pre>
  
  <p>Based on linked question, I used this </p>
  
  <pre><code> find . | xargs -0 -n1 -P8 grep -H "string"
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>xargs: argument line too long
  </code></pre>
  
  <p>Does anyone know a way to accomplish this task relatively quicker?</p>
  
  <p>I run this search on a server machine which has more than 50GB of available RAM, and 14 cores of CPU. I wish somehow I could use all that processing power to run this search faster.</p>