grep -c 'pattern' file.txt

Category: Text Processing

grep -c 'pattern' file.txt

Count the number of matching lines

Counts and prints how many lines in the file match the pattern, instead of showing the lines themselves.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.