Grep |
grep is a command line interface utility originally written for use with the Unix operating system. The default behaviour of grep takes a regular expression on the command line, reads standard input or a list of files, and outputs the lines containing matches for the regular expression.
The name comes from a command in the Unix text editor Ed that takes the form:
:g/ re /p
This means search globally for matches to the regular expression re , and print lines where they are found . There are various command line switches available when using grep that modify the default behaviour.
==Variations==
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. Tcgrep is a rewrite of grep and uses Perl regular expression syntax. All these variations of grep have been ported to many computer operating systems.
Many other commands contain the word grep. GNU s pgrep, for instance, displays the process numbers of the processes which name match a regular expression.
===Used as a conversational verb=== As the name grep neatly fits the .
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.
=Examples=
To search all files in the working directory for the string foo .
:grep foo *
To search all files in the current directory and all its subdirectories for the string foo . (The character . is a relative path from the current directory to itself.)
:grep -r foo .
As above, but only output the names of files containing the string foo .
:grep -lr foo .
=External links=
*[http://unixhelp.ed.ac.uk/CGI/man-cgigrep grep s GNU man page] *[http://www.gnu.org/software/grep/doc/ GNU Project documentation for grep] *[http://www.cpan.org/modules/by-authors/id/TOMC/scripts/tcgrep.gz source for Tcgrep] *AIX documentation **[http://www.unet.univie.ac.at/aix/cmds/aixcmds2/grep.htm AIX documentation for grep] **[http://www.unet.univie.ac.at/aix/cmds/aixcmds2/fgrep.htm AIX documentation for fgrep] **[http://www.unet.univie.ac.at/aix/cmds/aixcmds2/egrep.htm AIX documentation for egrep] *Alternatives For Microsoft Windows Users **[http://www.wingrep.com Windows GREP] **[http://www.powergrep.com PowerGREP for Windows] **[http://www.interlog.com/~tcharron/grep.html Modified GNU grep 2.0]|
|