title: How to find directories (not) containing a certain file efficiently
body: <p>I need to list all directories that contain <a href="http://www.brynosaurus.com/cachedir/" rel="nofollow">CACHEDIR.TAG</a> file, or to list all that don't. So far, I came up with
  </p>
  
  <pre class="lang-sh prettyprint-override"><code>find ~ -type d -exec test -f {}/CACHEDIR.TAG ';' -print
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-sh prettyprint-override"><code>find ~ -type d -exec test -f {}/CACHEDIR.TAG ';' -prune -o -type d -print
  </code></pre>
  
  <p>However, <code>test -f ...</code> feels a bit cumbersome and calling on every directory makes it painfully slow. For example, it takes over 30 seconds on my test directory, while plain <code>find ~ -type d</code> takes less than 1 second (tested after everything was cached into memory).</p>
  
  <p>Anybody knows a better/faster solution?</p>