Turning Off Regular Expression Wildcards

To turn off the special nature of a regular expression wildcard, precede it with a backslash, as in this example:

grep '2\*3' mathreport

Here, you are looking for the string 2*3, so you have to turn off the special meaning of the asterisk.

Two Reasons to Avoid fgrep

fgrep is supposed to be the fast grep because it does not have to handle regular expressions. However, it is often the slowest of the grep commands. The X/Open (Ver 2) spec calls fgrep obsolete and prefers the equivalent command grep -F.

If you have a large number of wildcards to turn off, you can use the fgrep command, which does not allow any regular expression wildcards. All characters are regular characters to fgrep. Therefore, with this ...

Get Practical UNIX 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.