Although grep is not strictly an acronym, the letters are taken from global / regular expression / print, a series of instructions for the ed text editor. The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.
In this case, grep prints all lines containing 'apple' from the file fruitlist.txt, regardless of word boundaries; therefore lines containing 'pineapple' or 'apples' are also printed. The grep command is case sensitive by default, so this example's output does not include lines containing 'Apple' (with a capital A) unless they also contain 'apple'.
Like most Unix commands, grep accepts command line arguments to change this and many other behaviors. For example:
This prints all lines containing 'apple' regardless of capitalization. The '-i' argument tells grep to be case insensitive, or to ignore case.
To print all lines containing 'apple' as a word ('pineapple' and 'apples' will not match):
For further details on grep command line arguments and regular expression capabilities/syntax, refer to the particular implementation's documentation.
-Frespectively in GNU grep). In such combined implementations, grep may also behave differently depending on the name by which it is invoked, allowing fgrep, egrep, and grep to be links to the same program.
Tcgrep is an implementation of grep that uses Perl regular expression syntax.
Other commands contain the word 'grep' to indicate that they search (usually for regular expression matches). The pgrep utility, for instance, displays the processes whose names match a given regular expression.
The DOS, OS/2 and Microsoft Windows platforms provide the find command for simple string searches. Windows also provides the "findstr" command which approximates much of the functionality of "grep", or you can use the cygwin grep ported version.
In December 2003, the Oxford English Dictionary Online added draft entries for "grep" as both a noun and a verb.
A common usage is the phrase "You can't grep dead trees" - meaning computerized documentation is better than printed documentation (paper is made from dead trees) because computers can search documents by using tools such as grep.
The word "grep" has also become a synonym for regular expressions themselves. Many text and word processors now employ regular expression search features, which those applications will often refer to as a "grep tool" or "grep mode" in which one creates "grep patterns", causing confusion, especially in non-Unix environments.