UNIX Shells by Example

 in
If you want to learn shell programming, this book is a must-have.
  • Author: Ellie Quigley

  • Publisher: Prentice Hall

  • E-mail: corpsales@prenhall.com

  • URL: http://www.phptr.com/

  • Price: $49.95 US

  • ISBN: 0-13460-866-6

  • Reviewer: Ben Crowder

Unix Shells by Example truly fulfills the claim made in the title: over 630 examples are in the book, plus another 60 in the first appendix. If you want to learn shell programming, this book is a must-have.

The first chapter introduces the three major shells: the Bourne shell, the C shell and the Korn shell. The Bourne Again shell (bash), the one used by most Linux users, isn't specifically covered, but the information on the other three shells usually applies. A history of each shell, plus the theory behind shells is given. Where the shell comes in on a UNIX system is described, as well as more general UNIX topics such as file attributes and permissions.

Chapter Two, “The UNIX Tool Box”, gives a very useful explanation of regular expressions which applies to much more than shell programming; for example, searching for text within Emacs or vim is built on basically the same principle. Over the next six chapters, what are considered to be three of the more important UNIX tools in regard to shell programming are covered.

Our friend grep appears in the third chapter—the meaning behind the name, how it works, and how to use it (with, of course, extensive examples). Chapter Four covers sed, the Streamlined Editor—again, replete with examples.

The next three chapters describe awk--the history, the input format, records and fields, patterns and actions, script files, comparison expressions, variables, pipes, loops and arrays, to name just a few topics. This section is quite extensive and very useful. I would have to agree with the author that these three are among the most important of all text processing utilities.

Each of the three major shells is covered in a separate chapter. Chapter Eight introduces the Bourne shell, discussing topics such as variables, metacharacters, file-name substitution, pipes, functions, arithmetic, looping and the built-in shell commands, in addition to many other subjects of interest.

The C shell appears in the next chapter. Each shell is given basically the same treatment: the first section of the chapter is devoted to the interactive shell (aliases, job control, the environment, redirection, etc.), while the second section covers programming in that shell (loops, flow control, arithmetic, etc.). Chapter Ten goes over the Korn shell in the same manner.

Appendix A lists useful utilities for shell programmers. These are stock UNIX programs, such as at, mv, passwd and so on. Quite a few examples are given (sixty, to be precise), as well as usage information and a short description. Appendix B provides a table for comparing the three shells. This is an invaluable resource for those who need to port shell scripts from one shell to another. For example, the table shows you how, in each shell, to assign the output of a command to a variable. In the C shell you use set d='date', in the Bourne shell you use d='date', and in the Korn shell you use d=$(date) or d='date'. Appendix C explains clearly and concisely how to use quoting correctly, especially for those tricky problems where you have multiple layers of quotes. The attached CD comes with all source code given in the book.

So, is the book worth your time and money? Yes, very much so. I found the examples to be particularly helpful, illustrating concepts far more clearly than prose could possibly do. If you're interested in shell programming, or even if you're just curious about shells in general, get over to your local bookstore and buy this book.

Ben Crowder is a young Linux aficionado living in Utah. In addition to fiddling with the insides of computers, Ben enjoys reading, writing and music. He can be reached at mlcrowd@enol.com.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState