ABSTRACT

Chapter 5 explores regular expressions: what they are, how to use them and Linux tools that apply them. After motivating how regular expressions can be applied in a spam filter, coverage of regular expressions is handled by introducing each of the regular expression metacharacters available in Linux. With every metacharacter introduced are numerous example regular expressions. Next, the grep/egrep program is explored both in terms of usage and the more common options. The sed program is introduced, primarily demonstrating the use of the search and replace form of script. The awk program is then examined to provide enough of an introduction so that the reader can write basic awk commands. Also demonstrated is piping Linux commands to grep and awk to select specific output from the Linux commands. Throughout the chapter, numerous examples are presented.