The best-selling Unix Shells by Example
continues to be the only book you need to learn Unix shell programming. Unix Shells by Example, Third Edition
adds thorough coverage of the new bash and tcsh shells to the full explanations in Quigley's famous treatment of the C, Bourne, and Korn shells and the awk, sed, and grep utilities, making this the most complete Unix shell programming book available anywhere.
Using proven techniques drawn from her acclaimed Silicon Valley Unix classes, Quigley transforms you into an expert-level shell programmer. You'll learn what the shells are, what they do, and how to program them, as well as how and when to use awk, sed, and grep. Code examples, completely revised and classroom-tested for this edition, explain concepts first-hand and can serve as the basis for your own projects.
Playing the "shell" game is a lot of fun. This book was written to make your learning experience both fun and profitable. Since the first edition was published, many of you who have been helped by my book have contacted me, telling me that the book made you realize that shell programming doesn't need to be difficult at all! Learning by example makes it easy and fun. In fact, because of such positive feedback, I have been asked by Prentice Hall to produce this fourth edition of UNIX(R) Shells by Example for UNIX and Linux users, programmers, and administrators. Along with updated material throughout, it includes three completely new chapters, with full coverage of the GNU tools for those of you who use Linux. With the meteoric rise of Linux popularity, it seemed like a good time to combine the best of Linux Shells by Example with UNIX(R) Shells by Example and produce a single volume that touches on all the various aspects of the UNIX/Linux shell world.
The new chapters include Chapter 2, "Shell Programming QuickStart," an introductory jump-start for programmers who want a quick survey of the shell programming constructs and how they differ; Chapter 15, "Debugging Shell Scripts," which gives you an example of an error message, what caused it, and how to fix it; and Chapter 16, "The System Administrator and the Shell," which demonstrates how the shell is used by system administrators, from system boot-up to shutdown.
Writing UNIX(R) Shells by Example was the culmination of 21 years of teaching and developing classes for the various shells and UNIX/Linux utilities most heavily used by shell programmers. The course notes I developed have been used by the University of California, Santa Cruz; the University of California, Davis; Sun Microsystems; Apple Computer; Xilinx; National Semiconductor; LSI Logic; De Anza College; and numerous vendors throughout the world. Depending upon the requirements of my client, I normally teach one shell at a time rather than all of them at once. To accommodate the needs of so many clients, I developed separate materials for each of the respective UNIX/Linux shells and tools.
Whether I am teaching "Grep, Sed, and Awk," "Bourne Shell for the System Administrator," "The Interactive Korn Shell," or "Bash Programming," one student always asks, "What book can I get that covers all the shells and the important utilities such as grep, sed, and awk? How does awk differ from gawk? Will this work if I'm using Linux or is this just for Solaris? Should I get the awk book, or should I get a book on grep and sed? Is there one book that really covers it all? I don't want to buy three or four books in order to become a shell programmer."
In response, I could recommend a number of excellent books covering these topics separately, and some UNIX and Linux books that attempt to do it all, but the students want one book with everything, and not just a quick survey. They want the tools, regular expressions, all the major shells, quoting rules, a comparison of the shells, exercises, and so forth, all in one book. This is that book.
As I wrote it, I thought about how I teach the classes and organized the chapters in the same format. In the shell programming classes, the first topic is always an introduction to what the shell is and how it works. Then we talk about the utilities such as grep, sed, and awk--the most important tools in the shell programmer's toolbox. When learning about the shell, it is presented first as an interactive program where everything can be accomplished at the command line, and then as a programming language where the programming constructs are described and demonstrated in shell scripts. (Since the C and TC shells are almost identical as programming languages, there are separate chapters describing interactive use, but only one chapter discussing programming constructs.)
It's one thing to write a script, but yet another to debug it. I have been working with the shells for so long, that I can recognize bugs in a program almost before they happen! But these bugs are hard to find until you get used to the error messages and what they mean. I added a chapter on debugging to help you understand what the often cryptic error messages mean and how to fix them. Since the diagnostics for the shells may differ, each shell is presented with the most common error messages and what caused them.
Many students take a shell course as a step toward learning system administration. Susan Barr, a teaching colleague of mine who teaches system administration and shell programming, offered to share her extensive knowledge and write a chapter to describe how the system administrator uses the shell (Chapter 16, "The System Administrator and the Shell").
Another aid to comprehension is that the five shells are discussed in parallel. If, for example, you're working in one shell but want to see how redirection is performed in another shell, you will find a parallel discussion of that topic presented in each of the other shell chapters.
It can be a nuisance to shuffle among several books or the man pages when all you want is enough information about a particular command to jog your memory on how a particular command works. To save you time, Appendix A contains a list of useful UNIX and Linux commands, their syntax, and definitions. Examples and explanations are provided for the more robust and often-used commands.The comparison table in Appendix B will help you keep the different shells straight, especially when you port scripts from one shell to another, and serves as a quick syntax check when all you need is a reminder of how the construct works.
I think you'll find this book a valuable tutorial and reference. The objective is to explain through example and keep things simple so that you have fun learning and save time. Since the book replicates what I say in my classes, I am confident that you will be a productive shell programmer in a short amount of time. Everything you need is right here at your fingertips. Playing the shell game is fun . . . You'll see!
--This text refers to an alternate