Errata for Unix Shell Programming

Errata for Unix Shell Programming

tr command - Page 80, 81, 83

There is an error in the description of the tr command. On page 80-81 the book describes how to use ranges of characters with tr. The first example is:

tr '[a-z]' '[A-Z]' < intro

This works but is wrong! tr does not use square brackets with it's ranges. This should be written as:

tr a-z A-Z < intro

(quotes optional). The reason it works is because the [ is replaced with a [ and the ] with a ]. If your ranges were not the same length, though it would not produce the expected result. For example:

tr '[a-z]' '[A-M]' < intro

You would expect m-z to be replaced with M but n-z would be replaced with ] instead!

The same holds for the example at the top of page 81 and the table of examples on page 83.