git grepコマンドでファイル毎にマッチした数を表示する方法
git grepコマンドでファイル毎にマッチした数を表示するには-cオプションを指定します。
オプションの説明
-c, --count Instead of showing every matched line, show the number of lines that match.
-cオプションを指定した場合
$ git grep -c time_t | head Documentation/RelNotes/2.14.0.txt:1 Documentation/git-grep.txt:2 archive-zip.c:2 archive.c:1 blame.c:1 builtin/bugreport.c:1 builtin/pack-objects.c:1 commit-graph.c:1 commit-reach.c:2 commit-reach.h:1
-cオプションを指定しない場合
$ git grep time_t | head Documentation/RelNotes/2.14.0.txt: * Some platforms have ulong that is smaller than time_t, and our Documentation/git-grep.txt:`git grep 'time_t' -- '*.[ch]'`:: Documentation/git-grep.txt: Looks for `time_t` in all tracked .c and .h files in the working archive-zip.c: time_t time; archive-zip.c: time = (time_t)*timestamp; archive.c: time_t archive_time; blame.c: time_t now; builtin/bugreport.c: time_t now = time(NULL); builtin/pack-objects.c: time_t last_mtime = 0; commit-graph.c: time_t now = time(NULL);