Number of files containing a given string

grep -l "string" * | wc -l will search for "string" in the contents of all files in the working directory and tell you how many matched.


greps parameter -l will only output the filenames which are matching $PATTERN, wc can count them afterwards.

grep -l "$PATTERN" * | wc -l

awk '/pattern_to_look_for/ {s+=1; nextfile;} END {print s}' *

Clarification: This looks for the number of files that has the "pattern_to_look_for" in their contents and not in their filenames (like Wag's answer). From your question it's hard to tell what you are looking for.