grep
Print lines matching a pattern
Overview
The grep command searches for PATTERNS in each FILE. A PATTERN is a sequence of characters that can be a fixed string or a regular expression. grep prints each line that matches a pattern.
Syntax
grep [OPTIONS] PATTERN [FILE...]Common Options
-i, --ignore-caseIgnore case distinctions in patterns and input data.
-v, --invert-matchInvert the sense of matching, to select non-matching lines.
-n, --line-numberPrefix each line of output with the 1-based line number within its input file.
-r, -R, --recursiveRead all files under each directory, recursively. Follow symbolic links on the command line, but skip symlinks encountered recursively.
-l, --files-with-matchesSuppress normal output; instead print the name of each input file from which output would normally have been printed.
-c, --countSuppress normal output; instead print a count of matching lines for each input file.
-E, --extended-regexpInterpret PATTERN as an extended regular expression (ERE).
-F, --fixed-stringsInterpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched.
-w, --word-regexpSelect only those lines containing matches that form whole words.
Examples
Search for the word "error" in logfile.txt.
Search for "hello" (case-insensitive) in myfile.txt.
Recursively search for "config_value" in all files under /etc/.
Display all lines from config.conf that do not start with # (comments).
List all C files (*.c) that contain the word "main".
Find processes related to firefox.