Use grep -c to count the number of input lines containing a given pattern.

# number of input lines containing 'a'
$ printf 'goal\nrate\neat\npit' | grep -c 'a'
3

# number of input lines containing all the vowels
$ grep -icP '^(?=.*a)(?=.*e)(?=.*i)(?=.*o).*u' /usr/share/dict/words
640

# number of input lines NOT containing 'at'
$ printf 'goal\nrate\neat\npit' | grep -vc 'at'
2

With multiple file input, count is displayed for each file separately. Use cat if you need a combined count.

# separate count for each input file
$ seq 15 | grep -c '1' programming_quotes.txt -
programming_quotes.txt:1
(standard input):7

# total count for all the input files
$ cat <(seq 15) programming_quotes.txt | grep -c '1'
8

If total number of matches is required, use the -o option to display only the matching portions (one per line) and then use wc to get the count.

# -c gives count of matching lines only
$ printf 'goal\nrate\neat\npit' | grep -c '[aeiou]'
4

# use -o to get each match on a separate line
$ printf 'goal\nrate\neat\npit' | grep -o '[aeiou]' | wc -l
7

Note that if you use ripgrep, you can also use -co or --count-matches instead of piping to wc command.

# this behavior is different compared to GNU grep
$ printf 'goal\nrate\neat\npit' | rg -co '[aeiou]'
7

info See my GNU GREP and RIPGREP ebook if you are interested in learning about GNU grep and ripgrep commands in more detail.