Main Page | See live article | Alphabetical index


grep is a command line utility originally written for use with the Unix operating system. The name comes from a command in the Unix text editor ed that takes the form g/re/p meaning search globally for a regular expression and print lines where instances are found. This describes the default behaviour of the grep command. Grep takes a regular expression on the command line, reads standard input or a list of files, and outputs the lines that match the regular expression. There are various command line switches available when using grep that modify that default behaviour.

There are many derivatives of grep, for example agrep which stands for approximate grep to facilitate fuzzy string searching, fgrep for fixed pattern searches and egrep for searches involving more sophisticated regular expression syntax. All these variations of grep have been ported to many computer operating systems.

The Perl programming language provides a pattern matching function named grep, as do other languages.

Grep is often used as a verb, a synonym of search, e.g., "I grepped the Wikipedia for an article on Unix searching and found it here."