find all files containing specific text / pattern
List the files containing pattern
grep -ril ['PATH'] -e 'PATTERN'
in current path:
grep -ril ./ -e 'PATTERN'
count them only:
grep -ril ./ -e 'PATTERN' | wc -l
where
-
-rrecursive lazy - read all files under each directory, recursively, following symbolic links only if they are on the command line. Note that if no file operand is given, grep searches the working directory. This is equivalent to the -d recurse option. -
-l(lower-case L) show the file name, not the result itself
more options
-
-nshow line number -
-Rrecursive greedy - read all files under each directory, recursively. Follow all symbolic links, unlike -r. -
-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
No comments to display
No comments to display