grep -Ril "text-to-find-here" "directory path"
i
stands for upper/lower case (optional in your case).R
stands for recursive.l
stands for "show the file name, not the result itself`.
grep -rnw 'directory' -e "pattern" # this works for me all the time.
r
is recursiven
is line numberw
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. Similarly a sample use of --exclude:
grep --exclude=*.o -rnw 'directory' -e "pattern"
- Above will exclude searching all the files ending with .o extension.
grep -Ir --exclude=*.{c,h} "pattern" *
- -I Ignores binary files