Solaris Advanced User's Guide

Using Regular Expressions With grep

You can also use the grep command to search for targets that are defined as patterns by using regular expressions. Regular expressions consist of letters and numbers, in addition to characters with special meaning to grep. These special characters, called metacharacters, also have special meaning to the system. When you use regular expressions with the grep command, you need to tell your system to ignore the special meaning of these metacharacters by escaping them. When you use a grep regular expression at the command prompt, surround the regular expression with quotes. Escape metacharacters (such as & ! . * $ ? and \) with a backslash (\). See Searching for Metacharacters for more information on escaping metacharacters.