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'

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

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

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 -
(standard input):7

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

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]'

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

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]'

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