You are here

Finding files containing a string

To find all *.h and *.c files in directory <directory> and its subdirectories, containing string <string>:

grep -e "<string>" -rn --include=*.{h,c} <directory>

with:

  • -r: read files  under  each  directory,  recursively
  • -n: prefix  each  line of output with the 1-based line number within its input file