How do I use grep to search the current directory for all files having the a string "hello" yet display only .h and .cc files?

stackoverflow picture stackoverflow · Feb 9, 2012 · Viewed 252.4k times · Source

How do I use grep to search the current directory for any and all files containing the string "hello" and display only .h and .cc files?

Answer

stackoverflow picture stackoverflow · Feb 9, 2012
grep -r --include=*.{cc,h} "hello" .

This reads: search recursively (in all sub directories also) for all .cc OR .h files that contain "hello" at this . (current) directory

From another stackoverflow question