find all files containing specific text / pattern
List the files containing pattern
grep -rl ['PATH'] -e 'PATTERN'
in current path:
grep -rl ./ -e 'PATTERN'
where
-
-rrecursive lazy -
-l(lower-case L) show the file name, not the result itself
more options
-
-nshow line number -
-Rrecursive greedy -
-istands for ignore case -
-wstands for match the whole word -
-oprint only the matched (non-empty) parts of a matching line, with each such part on a separate output line -
--color=automark up the matching text -
--includeExample:--include=\*.{c,h}will only search through those files which have .c or .h extensions -
--excludeExample:--exclude=*.owill exclude searching all the files ending with .o extension -
--exclude-dirExample:--exclude-dir={dir1,dir2,*.dst}will exclude the dirs dir1/, dir2/ and all of them matching *.dst/
PATTERN is normally case sensitiv
man page: http://man7.org/linux/man-pages/man1/grep.1.html