title: Count total number of matches in directory with ag
body: <p>I'm attempting to find the number of matches for a given string across a large project. Currently, to do this with <code>ag</code> I am using the following command: </p>
  
  <pre><code>$ echo 0$(ag -c searchterm | sed -e "s/^.*:/+/") | bc
  </code></pre>
  
  <p>which is obviously a bit lengthy and not very intuitive. Is there any better way to get the total number of matches in a directory from <code>ag</code>? I've dug through the documentation and couldn't find anything helpful there.</p>
  
  <p>Edit: Thanks to a <a href="https://github.com/ggreer/the_silver_searcher/commit/df5d456b355f0ffaceef63aeba92dfa3e413571b" rel="noreferrer">recent commit</a> to <code>ag</code>, the filenames can be stripped with <code>ag</code> instead of <code>sed</code>, so this also works:</p>
  
  <pre><code>$ echo `ag test -c --nofilename | sed "s/$/+/"`0 | bc
  </code></pre>
  
  <p>Note: I realize I could do this with <code>ack -hcl searchterm</code> (Well, almost. In my specific case I'd need an <code>--ignore-dir building</code> in there as well), but as this is already a large project (and will be growing considerably), the speed boost offered by <code>ag</code> makes it preferable (<code>ack</code> takes about 3 seconds for my searches vs <code>ag</code>'s nearly instantaneous result), so I would like to stick with it.</p>