grep is a command-line text-search utility originally written for Unix. It uses regular expressions to match text, and is commonly used as a filter in pipelines. Use this tag only if your question relates to programming using grep or grep-based APIs. Questions relating to using or troubleshooting grep command-line options itself are off-topic.
The name comes from ed and similar editors, and is derived from global / regular expression / print.
Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was originally developed for the Unix operating system, but is available today for all Unix-like systems.
The following are the several implementations of grep available in some Unix environments:
- egrep: same as
grep -E- Interprets the pattern as an extended regular expression.
- fgrep: same as
grep -F- Interprets the pattern as a list of fixed strings, separated by newlines, any of which is to be matched.
- pgrep: displays the processes whose names match a given regular expression.
-f file- Obtain patterns from file, one per line.
-i- Ignore case distinctions in both the pattern and the input files.
-o- Show only the part of a matching line that matches the pattern.
-c- Print a count of matching lines for each input file.
-R- Read all files under each directory, recursively.
-v- Invert the sense of matching, to select non-matching lines.
Other Stack Exchange sites
- tagged grep on Unix & Linux
- tagged grep on Ask Ubuntu
- tagged grep on Super User
- tagged grep on Server Fault
- grep Pocket Reference - "A quick pocket reference for a utility every Unix user needs"