Using regular expressions with grep

In addition to using grep to search for simple text strings, you can also use grep to search for regular expressions. Regular expressions are kind of like fancy wildcards, where you use a symbol to represent a character, number, or other symbol. With regular expressions, you can search for different parts of files, such as the end of a line or a text string next to another specified text string. Table 6.1 lists some of the more common regular expressions.

To use regular expressions with grep:

  • grep .logan limerick
    Type grep followed by the regular expression and the file name. Here, we've used the regular expression .logan to find all instances of "logan" or "slogan" (Code Listing 6.9). Note that this usage ...

Get Unix: Visual QuickStart Guide 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.