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}

with:

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