3. Tools of the Trade

This chapter provides detailed descriptions of some commonly used shell programming tools. Covered are cut, paste, sed, tr, grep, uniq, and sort. The more proficient you become at using these tools, the easier it will be to write efficient shell scripts.

Regular Expressions

Before getting into the tools, you need to learn about regular expressions. Regular expressions are used by many different Unix commands, including ed, sed, awk, grep, and, to a more limited extent, the vi editor. They provide a convenient and consistent way of specifying patterns to be matched.

Where this gets confusing is that the shell recognizes a limited form of regular expressions with filename substitution. Recall that the asterisk (*) specifies ...

Get Shell Programming in Unix, Linux and OS X, Fourth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.