Register your product to gain access to bonus material or receive a coupon.
Five UNIX shells, three essential utilities, one indispensable resource!
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.
UNIX system administrators, application developers, and power users will turn to this book again and again, both as a vital classroom learning tool and as a favorite reference manual.
About the CD-ROMProvides source code and data files for all examples in the book!
Preface.
1. Introduction to UNIX Shells.
Definition and Function. System Startup and the Login Shell. Processes and the Shell. The Environment and Inheritance. Executing Commands from Scripts.
Regular Expressions. Combining Regular Expression Metacharacters.
The grep Command. grep Examples with Regular Expressions. grep with Pipes. grep with Options. egrep (Extended grep). Fixed grep or Fast grep.
What Is sed? How Does sed Work? Addressing. Commands and Options. Error Messages and Exit Status. sed Examples. sed Scripting.
What Is awk? awk's Format. Formatting Output. awk Commands from Within a File. Records and Fields. Patterns and Actions. Regular Expressions. awk Commands in a Script File. Review.
Comparison Expressions. Review.
Variables. Redirection and Pipes. Pipes. Closing Files and Pipes. Review. Conditional Statements. Loops. Program Control Statements. Arrays. awk Built-In Functions. Built-In Arithmetic Functions. User-Defined Functions (nawk). Review. Odds and Ends. Review.
Startup. Programming with the Bourne Shell.
The Interactive C Shell. Programming with the C Shell.
Interactive Korn Shell. Programming with the Korn Shell.
Introduction. Command Line Shortcuts. Variables.
Introduction. Reading User Input. Arithmetic. Positional Parameters and Command Line Arguments. Conditional Constructs and Flow Control. Looping Commands. Functions. Trapping Signals. Debugging. Processing Command Line Options with getopts. The eval Command and Parsing the Command Line. bash Options. Shell Built-In Commands.
Introduction. The TC Shell Environment. Command Line Shortcuts. Job Control. Metacharacters. Redirection and Pipes. Variables. Arrays. Special Variables and Modifiers. Command Substitution. Quoting. Built-In Commands.
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, I have heard from many of you who have been helped by my book to realize that shell programming doesn't need to be difficult at all! Learning by example makes it easy and fun. In fact, due to such positive feedback, I have been asked by Prentice Hall to produce this new, updated version to include two additional and popular shells, the Bash and TC shells. Although often associated with Linux systems, the Bash and TC shells are freely available to anyone using UNIX as well. In fact, today many UNIX users prefer these shells to the traditional UNIX shells because they offer an enhanced and flexible interactive environment, as well as improved programming capabilities.
Writing UNIX Shells by Example is the culmination of 19 years of teaching and developing classes for the various shells and those UNIX utilities most heavily used by shell programmers. The course notes I developed for teaching classes have been used by the University of California Santa Cruz and University of California Davis UNIX programs, Sun Microsystems Education, Apple Computer, DeAnza College, and numerous vendors throughout the world. Depending on the requirements of my client, I normally teach one shell at a time rather than all of them. To accommodate the needs of so many clients, I developed separate materials for each of the respective UNIX shells and tools.
Whether I am teaching "Grep, Sed, and Awk," "Bourne Shell for the System Administrator," or "The Interactive Korn Shell," one student always asks, "What book can I get that covers all the shells and the important utilities such as grep, sed, and awk? 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 can recommend a number of excellent books covering these topics separately, and some UNIX books that attempt to do it all, but the students want one book with everything and not just a quick survey. They want the UNIX tools, regular expressions, all three 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 UNIX 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.) When shell programming classes are over, whether they last two days or a week or even a semester, the students are proficient and excited about writing scripts. They have learned how to play the shell game. This book will teach how to play the same game whether you take a class or just play by yourself.
Having always found that simple examples are easier for quick comprehension, each concept is captured in a small example followed by the output and an explanation of each line of the program. This method has proven to be very popular with those who learned Perl programming from my first book, Perl by Example, and UNIX Shells by Example now has been well received for those who needed to write, read, and maintain shell programs.
The five shells are presented in parallel so that if, for example, you want to know how redirection is performed in one shell, there is a parallel discussion of that topic in each of the other shell chapters. For a quick comparison chart, see Appendix B of this book.
It is a nuisance to have to go to another book or the UNIX man pages when all you want is enough information about a particular command to jog your memory on how the command works. To save you time, Appendix A contains a list of useful commands, their syntax and definitions. Examples and explanations are provided for the more robust and often-used commands.
The comparison chart in Appendix B will help you keep the different shells straight, especially when you port scripts from one shell to another, and serve as a quick syntax check when all you need is a reminder of how the construct works.
One of the biggest hurdles for shell programmers is using quotes properly. The section on quoting rules in Appendix C presents a step-by-step process for successful quoting in some of the most complex command lines. This procedure has dramatically reduced the amount of time programmers waste when debugging scripts with futile attempts at matching quotes properly.
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!
Ellie Quigley (ellieq@ellieq.com
)
We are making available as a PDF a revised index for UNIX Shells by Example, 3rd Edition.