Previous slide Next slide Back to the first slide View text version


Notes:

The first example will print out those line which don’t end with the period (.) in the fortunes file. Notice the characters range within square braces:

Thus, lines 1, 11, 15, 16, 18, 24, 33, 34, and 36 satisfies the expression. When a period is placed in square braces, the special meaning is negated. However, my preference is to still include the backslash to eliminate any confusion for those who aren’t that familiar with UNIX regular expressions.

In the second example we want to match those records, in the /etc/passwd file, where the first character is a “s” character at the beginning of the line; the next (second) is a "t"; the third is an "u"; the fourth is a “0" (zero); the fifth character is anything that doesn’t match a digit ranging from "2" thru "6"; and the sixth character is an "a".