O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Pattern Matching

A number of Linux text-processing utilities let you search for, and in some cases change, text patterns rather than fixed strings. These utilities include the editing programs ed, ex, vi, and sed; the gawk programming language; and the commands grep and egrep. Text patterns (called regular expressions in computer science literature) contain normal characters mixed with special characters (called metacharacters).

Perl’s regular expression support is so rich that it does not fit into this book; you can find a description in the O’Reilly books Mastering Regular Expressions by Jeffrey E.F. Friedl, Regular Expression Pocket Reference by Tony Stubblebine, Perl in a Nutshell by Nathan Patwardhan et al., or Perl 5 Pocket Reference by Johan Vromans. The Emacs editor also provides regular expressions similar to those shown in this chapter. See the O’Reilly books Learning GNU Emacs by Debra Cameron et al., or GNU Emacs Pocket Reference, also by Debra Cameron, for details.

This chapter presents the following topics:

  • Filenames versus patterns

  • Description of metacharacters

  • List of metacharacters available to each program

  • Examples

For more information on regular expressions, see the aforementioned O’Reilly book Mastering Regular Expressions.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required