title: Piping find results into grep for fast directory exclusion
body: <p>I am successfully using find to create a list of all files in the current subdirectory, excluding those in the subdirectory "cache." Here's my first bit of code:</p>
  
  <pre><code>find . -wholename './cach*' -prune -o -print
  </code></pre>
  
  <p>I now wish to pipe this into a grep command. It seems like that should be simple:</p>
  
  <pre><code>find . -wholename './cach*' -prune -o -print | xargs grep -r -R -i "samson"
  </code></pre>
  
  <p>... but this is returning results that are mostly from the cache directory. I've tried removing the xargs reference, but that does what you'd expect, running the grep on text of the file names, rather than on the files themselves. My goal is to find "samson" in any files that aren't cached content.</p>
  
  <p>I'll probably get around this issue by just using doubled greps in this instance, but I'm very curious about why this one-liner behaves this way. I'd love to hear thoughts on a way to modify it while still using these two commands (as there are speed advantages to doing it this way). </p>
  
  <p>(This is in CentOS 5, btw.)</p>