grep

grep (global regular expression processor) is a utility program that searches a file, or files, for lines that contain a particular string pattern. Unlike the find command, which searches directory structures for files that meet certain criteria, grep searches files for lines that contain a particular pattern.

We can use grep to search for a simple fixed character string, or it can be used to search for more complex patterns called “regular expressions.” First let’s take a look at the command syntax, and then I’ll describe how to use grep to search for simple strings.

The command syntax for the grep command is as follows:

grep <-options> search-pattern files-to-search
					

Some of the more common options to the grep command are described ...

Get Inside Solaris™ 9 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.