title: How to match once per file in grep?
body: <p>Is there any grep option that let's me control total number of matches but stops at first match on each file?</p>
  
  <p>Example:</p>
  
  <p>If I do this <code>grep -ri --include '*.coffee' 're' .</code> I get this:</p>
  
  <pre><code>./app.coffee:express = require 'express'
  ./app.coffee:passport = require 'passport'
  ./app.coffee:BrowserIDStrategy = require('passport-browserid').Strategy
  ./app.coffee:app = express()
  ./config.coffee:    session_secret: 'nyan cat'
  </code></pre>
  
  <p>And if I do <code>grep -ri -m2 --include '*.coffee' 're' .</code>, I get this:</p>
  
  <pre><code>./app.coffee:config = require './config'
  ./app.coffee:passport = require 'passport'
  </code></pre>
  
  <p>But, what I really want is this output:</p>
  
  <pre><code>./app.coffee:express = require 'express'
  ./config.coffee:    session_secret: 'nyan cat'
  </code></pre>
  
  <p>Doing <code>-m1</code> does not work as I get this for <code>grep -ri -m1 --include '*.coffee' 're' .</code></p>
  
  <pre><code>./app.coffee:express = require 'express'
  </code></pre>
  
  <p>Tried not using grep e.g. this <code>find . -name '*.coffee' -exec awk '/re/ {print;exit}' {} \;</code> produced:</p>
  
  <pre><code>config = require './config'
      session_secret: 'nyan cat'
  </code></pre>
  
  <p><strong>UPDATE: As noted below the GNU grep <code>-m</code> option treats counts per file whereas <code>-m</code> for BSD grep treats it as global match count</strong></p>