Questions tagged
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.

There are many programming languages which include a command or statement called grep; please simply use that language's tag for questions which do not pertain to the Unix utility.


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.

Common options

  • -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.

Frequently asked

  • How to find all files containing specific text on Linux?
  • How do I grep recursively?

Other Stack Exchange sites

  • tagged grep on Unix & Linux
  • tagged grep on Ask Ubuntu
  • tagged grep on Super User
  • tagged grep on Server Fault


  1. grep/egrep/fgrep man page
  2. pgrep man page
  3. POSIX grep man page
  4. GNU grep manual


  • grep Pocket Reference - "A quick pocket reference for a utility every Unix user needs"
  • GNU GREP and RIPGREP - Step by step guide with hundreds of examples and exercises. Includes detailed discussion on BRE/ERE/PCRE(2)/Rust regular expressions used in these commands.