pantonante
10/18/2017 - 8:25 AM

Find a string in source code files (grep)

My favorite command to find a string in source files

Description:

  • -r recursive search
  • -n show line in the file that matched the pattern
  • --color use colorful output
  • --include pattern matching the files you are looking into

The files can be also a wildcard (e.g. . or *)

grep -rn --color --include=\*.{c,h} "<PATTERN>" files