Fixed String Example

Fixed String Example

$ fgrep '^[AEIOU]' fortunes.

$ grep '^[AEIOU]' fortunes

A modem is a baudy house.

A truly wise man never plays leapfrog with a Unicorn.

A woman without a man is like a fish without a bicycle.

An elephant is a mouse with an operating system.

Any time things appear to going better, you have overlooked something.

Armadillo: Supplying weapons to a Spanish pickle.

E Pluribus UNIX

Every program is a part of some other program, and rarely fits.

If at first you don't succeed, give up, don't be a darn fool.

Old programmers never die. They just branch to a new address.

On a clear disk you can seek forever.

I must have slipped a disk; my pack hurts.

Previous slide Next slide Back to the first slide View Graphic Version

Notes:

As demonstrated in the first example, fgrep(1) does exact character string matches: Notice that there were no matches since it was looking for the string “^[AEIOU]”; instead of interpreting the regular expression as being: match any line where a vowel character is the first character on the respective line. This proves the point that fgrep doesn’t support UNIX regular expressions.

In example two we get the desired results of the regular expression of matching those lines that begin with a vowel at the beginning of a line. As a result, lines 2 thru 5, lines 7, 10, 11, 12, 17, 23, 25 and 27 satisfies the match (regular expression defined) from the fortunes file from the fortunes file.

We can often get the desired results using the grep command, however, grep doesn’t support the complete extended set of UNIX expressions as shown in the example on the next page.