The simplest character set is a single
character. The regular expression the
contains three character sets: t
, h
, and e
. It
will match any line that contains the string the
, including the word other
.
To prevent this, put spaces (·
) before and
after the pattern: ·the·
.
You can combine the string with an anchor.
The pattern ^From
:·
will match the lines of a mail
message (Section 1.21)
that identify the sender. Use this pattern with grep to print every address in your incoming mailbox. [If your
system doesn't define the environment variable MAIL
, try /var/spool/mail/$USER or possibly /usr/spool/mail/$USER. — SJC]
$USER
Section 35.5
% grep '^From: ' $MAIL
Some characters have a special meaning in regular expressions. If you want to
search for such a character as itself, escape it with a backslash (\
).
— BB