SPECIAL OFFERS
Keep up with new releases and promotions. Sign up to hear from us.
Register your product to gain access to bonus material or receive a coupon.
The complete guide to bash and tschPLUS grep, sed, and gawk!
CD-ROM: All source code and data files used in the book.
Learn Linux shell programming hands-on!
One book is all you need to learn Linux shell programming! Linux Shells by Example is your complete, step-by-step guide to both essential Linux shells-bash and tcshand three essential Linux shell programming utilities, grep, sed and gawk. Ellie QuigleySilicon Valley's top shell programming instructorstarts from scratch and gets you all the way to expert-level techniques! Through hundreds of classroom-proven examples, you'll learn what Linux shells are, what they do, and exactly how they integrate with other Linux utilities and processes. Master creating, running, and debugging shell scripts using grep, sed, gawk, and a whole lot more.
Whether you're a system administrator, application developer or power user, Linux Shells by Example is the most convenient, cost-effective way to learn Linux shell programming!
CD-ROM INCLUDEDCD-ROM contains all of the source code and datafiles from the book.
Click here for a sample chapter for this book: 0130147117.pdf
1. Introduction to Linux Shells.
Why Linux? Definition and Function of a Shell. 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. Extended grep (grep -E or egrep). Fixed grep (grep -F and fgrep). Recursive grep (rgrep). grep with Pipes. grep with Options. Linux Tools Lab.
What Is sed? Versions of sed. How Does sed Work? Addressing. Commands and Options. Error Messages and Exit Status. sed Examples. sed Scripting. Linux Tools Lab.
What's awk? What's nawk? What's gawk? 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. Linux Tools Lab.
Comparison Expressions. Review. Linux Tools Lab.
Variables. Redirection and Pipes. Pipes. Closing Files and Pipes. Review. Linux Tools Lab. Conditional Statements. Loops. Program Control Statements. Arrays. awk Built-In Functions. User-Defined Functions. Review. Linux Tools Lab. Odds and Ends. Review. Linux Tools Lab.
Introduction. Command Line Shortcuts. Variables. The Bourne Shell Lab Exercises.
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. The Bash Shell Lab Exercises.
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. The TC Shell Lab Exercises.
Steps in Creating a Shell Script. Reading User Input. Arithmetic. Debugging Scripts. Command Line Arguments. Flow Control and Conditional Constructs. Loops. Interrupt Handling. setuid Scripts. Storing Scripts. Built-In Commands. The TC Shell Lab Exercises.
tcsh versus csh. bash versus sh.
Playing the "shell" game has been a lot of fun with UNIX, and now with Linux as well. After publishing my previous book, UNIX Shells by Example, Mark Taub (the Prentice Hall acquisitions editor who keeps me writing books) suggested I write a Linux shells book. We both thought it would be "a piece of cake," or at least I did. After all, there shouldn't be much difference between the Bourne and Bourne Again shells, or between C and TC shells; Maybe just a few neat new figures, right? Wrong! This project was like writing a brand new book from scratch.
Although there are many similarities, the UNIX and Gnu tools and shells offer a plethora of new extensions and features. Linux offers not only the Gnu tools, but also a number of fully functional shells. Since I had already covered the Korn shell in detail in UNIX Shells by Example, I decided to concentrate on the two most popular Linux shells-Bourne Again shell (bash) and TC shell (tcsh).
Due to all the new features, enhancements, built-ins, etc., the shell chapters had to be split up, or they would have become unwieldy. What in the previous book consisted of two chapters has now become four. It was a lengthy, tedious process and when I had just about completed the bash chapter, I realized I was not using the most up-to-date version, so back to the drawing board I went. Since all of you will not necessarily be using the same version of bash, I have tailored this book to cover the old and the new versions.
The first section of this book presents the Gnu tools you will need to write successful shell programs-gawk, grep, and sed. These are the ideal tools for pattern matching, manipulating, text editing, and extracting data from pipes and files.
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.
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 then shell programming from UNIX Shells by Example. Linux Shells by Example should get you up to speed quickly and before you know it, you will be able to read, write, and maintain shell programs.
The 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, and for quick comparison there is a chart in Appendix B of this book.
It is a nuisance to have to go to another book or the Linux man page 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 a definition. 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 as a quick syntax check when all that you need is a reminder of how the construct works. It compares Korn, Borne, Bash, Tcsh, and C shells.
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 same time. 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 Linux shell game is fun. You'll see!
Ellie Quigleywww.ellieq.com