Count the lines from output using pipeline

Solution 1:

Since according to your question, you want to know how many files contain a pattern, you are interested in the number of files, not the number of pattern occurances.

For instance,

grep -l '[Gg]reen' *  | wc -l

would produce the number of files which contain somewhere green or Green as a substring.