Find text in linux files

Posted . Visible to the public.
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
Posted by Sandheep to Sandheep's deck (2014-02-19 08:03)