How to match once per file in grep?

后端 未结 6 1105
再見小時候
再見小時候 2021-02-06 20:38

Is there any grep option that let\'s me control total number of matches but stops at first match on each file?

Example:

If I do this grep -ri --include \'*

6条回答
  •  忘了有多久
    2021-02-06 21:09

    find . -name \*.coffee -exec grep -m1 -i 're' {} \;

    find's -exec option runs the command once for each matched file (unless you use + instead of \;, which makes it act like xargs).

提交回复
热议问题