Find text in linux files

grep -rnw 'directory' -e "text-to-search"

-r is recursive, -n is line number and -w stands match the whole word.

grep --include={*.c,*.h} -rnw 'directory' -e "pattern"

This will only search through the files which have .c or .h extensions.

grep --exclude=*.o -rnw 'directory' -e "pattern"

Above will exclude searching all the files ending with .o extension.

Sandheep