grep -rnw '/path/to/somewhere/' -e 'pattern'
-nis line number, and
-wstands for match the whole word.
-l(lower-case L) can be added to just give the file name of matching files.
Along with these,
--exclude-dir flags could be used for efficient searching.
Original Stack Overflow answer: https://stackoverflow.com/a/16957078/1059672