When I search a big folder, the matches scroll past and I still don’t know how many there were. ripgrep has a flag that answers that after the last result.
rg --stats GET access.log
The matches print as usual, then ripgrep adds a block of numbers at the end. On ripgrep 14.1.0, searching a three-line log file for GET gave this after the two matching lines:
2 matches
2 matched lines
1 files contained matches
1 files searched
157 bytes printed
231 bytes searched
0.000015 seconds spent searching
0.000778 seconds
The manual says ripgrep prints at least these statistics to stdout at the end of a search. It is useful for a quick check on a whole project:
rg --stats -t py 'TODO'
That tells you how many files were searched, which is a good way to notice that ripgrep skipped something. By default it ignores files from .gitignore and hidden files, so the number can be lower than you expect.
The difference between a match and a matched line matters when a line contains the pattern twice. matches counts every hit, matched lines counts lines. If you only want the per-file numbers without the lines, --count-matches prints the number of individual matches for each file. Plain -c counts lines instead, which is the one to use when you want to know how many lines contain the pattern.
One caveat: the manual says --stats is always switched on when you use --json. If a script reads that JSON, expect a summary message at the end of the stream.
Further reading: rg(1) manual, ripgrep project
Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get