3.15. Regular Expressions

In order to fully utilize the power of shell scripting, you need to master regular expressions.

3.15.1. A Brief Introduction to Regular Expressions

An expression is a set of characters that has an interpretation above and beyond its literal meaning. A quote symbol ("), for example, may denote speech by a person, ditto, or a meta-meaning for the symbols that follow. Regular expressions are sets of characters that UNIX endows with special features.

The main uses for regular expressions (REs) are text searches and string manipulation. An RE matches a single character or a set of characters.

"Sed & Awk", by Dougherty and Robbins (see Bibliography) gives a very complete and lucid treatment of REs.

3.15.2. Using REs in scripts

Sed, awk, and Perl, used as filters in scripts, take REs as arguments when "sifting" or transforming files or I/O streams.