| Lesson 6 || Using a backslash to turn off a characters meaning |
| Objective || Create regular expressions using the backslash ( |
Using a Backslash to turn off a Character's Meaning
Some characters retain their special meaning within quotes, whether single or double quotes. One example is the exclamation point (
!), used in command history. Other examples include the regular expression metacharacters themselves.
For instance, you may want to search for a literal asterisk character. When quotes alone do not help, you can use a backslash (
\). By placing a
\ before a character, you disable any special meaning it has.
Another issue is how to search for quotes, because quotes themselves have special meaning in forming arguments. When a regular expression contains a double quote, enclose the expression in single quotes.
When searching for items that contain a single quote, enclose the expression in double quotes.
The following Slide Show shows examples of searches using the backslash and other quoting situations.
Special Case Regular Expressions
In the next lesson, you will wrap up this module by reviewing key commands, terms, and concepts you have learned, and then take a quiz.
Grep Command - Exercise