grep

Definition of grep in The Network Encyclopedia.

What is Grep?

Stands for global regular expression print, a command in the UNIX operating system. Grep lets you search a file or multiple files for a specific pattern or string of characters and, if desired, replace it with a different string.

The output of grep is a display of each line of the file that contains the desired character string. You can use wildcards and other meta-characters to perform complex search and replace operations with grep. Grep is useful for searching for specific entries in text files such as log files, UNIX system error logs, or C program code files.

Grep example

Typing grep 'a[b-f]' log.txt searches the text file called log.txt for any lines that contain the character a immediately followed by b , c , d , e , or f.

NOTE

Shareware versions of the grep utility are available from third-party vendors for Microsoft Windows platforms. Grep can also be combined with other UNIX commands in scripts that can perform more complex search functions. For example, you can pipe the output of a verbose command into grep to display a more selective form of output.