Book Reviews


UNIX Programming: Methods and Tools

Reviewed By Chris Flatters


Chris Flatters is a scientific programmer who works with FORTRAN and (occasionally) C on UNIX and VMS systems. Outside working hours he fiddles with C and C++ on an IBM PC.

UNIX Programming: Methods and Tools is a tutorial introducing the UNIX shell and utilities. It mainly focuses on the Bourne shell but devotes one chapter to the C shell. The book, which is intended for those with little or no computing experience, discusses only the more general UNIX tools and does not cover the UNIX text processors (nroff and troff) or the specialized programming tools.

The book is well-organized. Each chapter begins by listing information that will be covered, and each chapter also includes an extensive set of exercises (some of the exercises include solutions at the end of the book) and suggestions for further reading. The author also includes experiments for the reader to try out at the keyboard. Finally, each chapter contains a number of tables summarizing commands, symbols and keywords covered in that chapter. Unfortunately the summary tables (and many other tables in the text) are poorly laid out and difficult to read. Also, they contain a number of serious misprints.

The opening chapter introduces the reader to the UNIX system. It contains a short history of the development of the UNIX system and explains the relation between the shell and the operating system. The user is taken through the log-on process and shown how to issue simple commands, including those that allow users to communicate with each other (write and mail). Unfortunately, the author assumes that the user's default log-in shell is the Bourne shell, which is not the case on many systems. Although the author notes that other shells exist he does not give any guidance on how they may be selected. There is also a curiously anachronistic note in that the author assumes that the erase character is set to # and the kill character (which erases a whole line) to @ (the reader is shown how to change these assignments with the stty command). These characters are indeed the defaults for the UNIX system but date back to the days when computer users had to talk to the computer using teletypes. This is no longer the case. Most UNIX systems now automatically redefine the erase and kill keys to be more suitable for terminals.

After basic training, the author presents the finer details of the UNIX file system. The level of detail is probably inappropriate to the beginner — the author suggests studying octal dumps of directories and discusses i-nodes (the internal structures used by UNIX to describe files). This section of the book does, however, contain useful information on setting file protections.

The author then introduces the user to the concept of processes and explains that the various ways of invoking a UNIX command may or may not involve the creation of a new child process. Although the author explains some important points, the discussion of processes is incomplete. For example, the fact that a new process must be created to handle the second and subsequent commands in a pipe (so that non-exported variables will be unknown to these commands) is overlooked.

Next, the book discusses shell programming proper. Shell programming is taught mainly by example. In many cases, the author presents a simple procedure and adds features in subsequent examples. This rudimentary approach is appropriate for the novice, but readers who have some programming experience will find progress painfully slow.

The author devotes a chapter to techniques for designing and building procedures. Although beginning programmers need to be exposed to this topic, some of the techniques are treated only superficially.

After shell programming, the author discusses the more advanced general-purpose UNIX utilities: the grep family of text searching programs; the stream editor, sed; and the awk pattern matching language. The description of grep and sed is basically solid but is marred by a garbled account of regular expressions. The book covers the original version of awk and not the more recent version described by Aho, Kernigan and Weinberger in The awk Programming Language (this development was probably too recent for inclusion). Nonethless, the reader is introduced to awk basics, including the relationship between awk and C.

The book concludes with a short description of the C shell. The description is by no means comprehensive, but it does present features of the C shell that are not available in the Bourne shell.

In the preface the author claims that the procedures developed in the examples throughout the book are intended to be useful tools. He does not, however, achieve his aim. Most of the more sophisticated examples are programs for playing word games rather than accomplishing any useful task. The author's intent was probably defeated by the comprehensive UNIX utilities.

Readers with even moderate programming experience will almost certainly find UNIX Programming: Methods and Tools pitched at too low a level. Although it does contain some useful information, I would also hesitate to recommend this book to a rank beginner. It has a number of flaws and gives the impression of being rather diffuse and academic. In many ways the book appears to be an introduction to programming using the UNIX shell. I don't think this approach will appeal to many UNIX users, most of whom (even the beginners) will want to use the shell to achieve some specific objective. These users will find that there is surprisingly little hard information in UNIX Programming: Methods and Tools and the information that is present is often made inaccessible by a poor index.

UNIX Programming: Methods and Tools
James F. Peters III
Harcourt-Brace-Jovanovich, 1988
447 pages
ISBN 0-15-593021-4