Definition - What does Global-Regular-Expression-Print (GREP) mean?
Global regular expression and print (GREP) is a command line text search utility used in Unix. The "grep" command searches files or standard input for lines that match a given regular expression. It then prints the matching lines to the program’s standard output.
Techopedia explains Global-Regular-Expression-Print (GREP)
The grep command allows a user to search one or more files for lines that contain a pattern.
A general example of the grep command format is "grep sat check.txt". This command prints all lines containing the text string "sat", regardless of word boundaries, from the file check.txt. For instance, if there are lines that contain text strings such as "fisat", "sat", "saturn", etc., all would be printed at the output terminal.
There are a variety of options used along with grep to display the output based on the requirement. A few of these options are:
- "-i" - Ignore case sensitivity
- "-b" - Display block number at beginning of every line
- "-l" - Display file names but not matched lines
- "-n" - Display matched lines and line numbers
- "-v" - Display lines that do not match
Variations of grep are available for many operating systems. Early variations of grep included the "egrep" and "fgrep" commands. Egrep searches a file for a pattern using regular expression syntax, fgrep searches for a fixed character string. These variants of grep are included in most modern grep implementations as command-line switches. Other commands contain the word "grep" to indicate that they are search utilities. The "pgrep" utility, for example, displays a list of process names that match a specified regular expression.