Classic Shell Scripting
Hidden Commands that Unlock the Power of Unix
By Arnold Robbins, Nelson H.F. Beebe
May 2005
Pages: 558
ISBN 10: 0-596-00595-4 |
ISBN 13: 9780596005955




(Average of 6 Customer Reviews)


Book description
An essential skill for Unix users and system administrators, shell scripts let you easily crunch data and automate repetitive tasks, offering a way to quickly harness the full power of any Unix system. This book provides the tips, tricks, and organized knowledge you need to create excellent scripts, as well as warnings of the traps that can turn your best efforts into bad shell scripts.
Full Description
Shell scripting skills never go out of style. It's the shell that unlocks the real potential of Unix. Shell scripting is essential for Unix users and system administrators-a way to quickly harness and customize the full power of any Unix system. With shell scripts, you can combine the fundamental Unix text and file processing commands to crunch data and automate repetitive tasks. But beneath this simple promise lies a treacherous ocean of variations in Unix commands and standards. Classic Shell Scripting is written to help you reliably navigate these tricky waters.
Writing shell scripts requires more than just a knowledge of the shell language, it also requires familiarity with the individual Unix programs: why each one is there, how to use them by themselves, and in combination with the other programs. The authors are intimately familiar with the tips and tricks that can be used to create excellent scripts, as well as the traps that can make your best effort a bad shell script. With Classic Shell Scripting you'll avoid hours of wasted effort. You'll learn not only write useful shell scripts, but how to do it properly and portably.
The ability to program and customize the shell quickly, reliably, and portably to get the best out of any individual system is an important skill for anyone operating and maintaining Unix or Linux systems. Classic Shell Scripting gives you everything you need to master these essential skills.
Browse within this book
Cover
| Table of Contents
| Colophon
Featured customer reviews

A sound guide to the POSIX shell,
September 24 2007
Submitted by
AjT
[
Respond |
View]
This is a very good introduction to the POSIX shell, as used on various Unix and Linux operating systems. The book covers the basics of how a shell works, how it can be used to write scripts and the standard Unix tool-kit that can be used to do powerful things quickly and easily.
The book is grounded in standard POSIX tools so does not take advantage of features present in the very latest Bash, Korn and Z shells, but it does mention that sometimes if you are willing to trade portability you can do things easier and quicker.
The book does not require a deep understanding of the Unix philosophy but it does help to have used the basic Unix/Linux tools in the past. As well as shell, the book covers the standard tool-kit such as cut, head, tail, grep, sed and a large chunk of awk.
The book is well written and organised and there are plenty of code snippets and explanations to keep you going. The book does not really cover the interactive use of shell, it really is all about scripting with shell as the title suggests.
If I have one problem with the book it is that there is an almost pathological avoidance of the dynamic languages such as Perl, Python and Ruby. Some of the longer shell examples would have been much better written in a more complete language such as Perl which are better suited to the larger tasks that shell is not designed for.
Combined with a good introductory books such as "Learning the Bash Shell" or "Learning the Korn Shell" you are well on the way to driving a Unix/Linux system without a mouse!
Perfect updated shell scripting reference,
July 11 2007
Submitted by
Henrik Kramshøj
[
Respond |
View]
Seeing the pretty unfair stars from bad reviews I thought I would share my views on this book, and I will only make a single review - as to not skew the stars like the beginner did ;-)
This book is one of my all-time favourites, and I recommend it again and again to people working with UNIX. This is one of the most important books if you are an administrator in charge of various UNIX based systems.
I come from a UNIX environment at the beginning of 1990's and have used UNIX systems like HP-UX, SunOS/Solaris, Linux (SLS to Kubuntu), OpenBSD and AIX - about 15+ years of UNIX.
During this time UNIX tools and scripting has evolved tremendously and I have been caught sometimes using "yesterdays" ways of doing things.
This book immediately taught me how to do things in better ways and told me why some of my old habits should go out the door ASAP.
This book does go from beginner, having the basics of how to create a script using #! but is very dense and could be combined with some introductory stuff - another book on your favourite shell perhaps.
Over the years you will enjoy this book when working with UNIX and researching how to do a shell script task in an efficient AND portable way. To me it is an instant classic!
Correction,
March 23 2007
Submitted by
freejak
[
Respond |
View]
I need to make a correction to my earlier review. There are some example scripts included beginning in Chapter 5. I must have blanked these out of my memory because of their painful associations.
This is a line from the first (first!) example:
sed -e 's=^\([^:]*\):[^/]*/\([^/]*\)/.*$=\1:\2=' < $USER | sort > $OFFICE
For Pete's sake, what ever happened to "Hello World"?
Read all reviews
If you want to start learning to write Shell scripts, don't start here,
March 22 2007
Submitted by
freejak
[
Respond |
View]
Yesterday I officially gave up on the "Classic Shell Scripting" book. I don't like to give up on stuff, but this was a frustrating waste of time for me. After 120 pages I had had enough of SED/Awk examples, massive regular expressions, snippets that didn't work and not a single actual example of a shell script. This is not a book from which to start to learn how to write shell scripts.
I see that the other reviewers here give O'Reilly a pass by making more or less the same observation (albeit in kinder/gentler terms). I will not. The authors state in the Preface that this *is* a book for beginners to use to learn how to write Shell scripts. This is not helping the reader. This book either needs a very substantial re-write or a new, more accurate title and presentation.
After some analysis based on reader reviews I am going to take this from the top using the ""KornShell Programming Tutorial" from HP Press, authored by Barry Rosenberg. This book has garnered a average 5 star rating in reader reviews at amazon.com. Looks like a better starting point to me.
USALUG.org Review of "Classic Shell Scripting",
March 12 2006
Submitted by
Crouse
[
Respond |
View]
USA Linux Users Group Book Review
Original review posted at: http://www.usalug.org/phpBB2/viewtopic.php?p=77554 ()
Reviewer: Crouse
Book Review: Classic Shell Scripting
Authors: Arnold Robbins, Nelson H.F. Beebe
Publisher: O'reilly
First Edition May 2005
ISBN: 0-596-00595-4
560 pages, $34.95 US, $48.95 CA, £24.95 UK
http://www.oreilly.com/catalog/shellsrptg/index.html ()
http://www.oreilly.com/catalog/shellsrptg/errata/shellsrptg.confirmed ()
This book is designed for intermediate to advanced Linux users. The book states in the preface that before reading the book you should know some things about shell scripting already. This book isn't for those new to shell scripting. In my opinion, it kind of picks up where "Learning the Bash Shell" from O'reilly left off. It compliments that book pretty well. Each chapter builds on the concepts and materials covered in the chapter before, so it's a book that is best read front to back and not just used as a reference, you will get more from it that way.
The chapters titles show the progression of the book in what i considered to be a pretty good order. Chapter one and two start off with the basic history, and you quickly move to the next chapters which are the bulk of the book. They are as follows.
Chapter 3 Searching and Substitutions
Chapter 4 Text Processing Tools
Chapter 5 Pipelines can do Amazing Things
Chapter 6 Variables, Making Decisions, and Repeating Actions
Chapter 7 Input and Output, Files, and Command Evaluation
Chapter 8 Production Scripts
Chapter 9 Enough Awk to be Dangerous
Chapter 10 Working with Files
Chapter 11 Extended Example
Chapter 12 Spellchecking
Chapter 13 Processes
Chapter 14 Shell Portability Issues and Extentions
Chapter 15 Secure Shell Scripts
Worthy of noting are the a couple of the appendix titles.
Appendix A. Writing Manual Pages
Appendix B. Files and Filesystems.
Personally, I think these could just have easily been additional chapters in the book. The book makes nice use of examples and generally gives very detailed and descriptive explanations of those examples. The book does indeed build upon previous examples and chapters, making this a very easy to read book. I've found a lot of books simply assume that you have covered topic X somewhere already, and are much more suited for simple reference than they are actually reading. This book is useful as a reference, but it is very suited for reading as well. A lot of the commands that are used have a detailed explanation of them, plus caveats at the bottom, which is something many man pages don't include. I found those interesting as well. They provided insight into why some commands might not work as expected.
The chapters also contained a huge number of (Item / Description) type boxes for almost everything. An example would be for "Print Escape Sequences" from Chapter 7.
------------------------------------------
Sequence.................. Description
\a ............. Alert character, usually the ASCII BEL character.
\b .............. Backspace
\c ............. Suppress any final newline in the output.
........ and on down the list of escape sequences (about 8 more items in the list)
------------------------------------------
I realize that this may sound "trivial", but putting those tables of data actually IN the chapters made it much more enjoyable to read than some other books on the same subject. I was not forever having to flip to the appendix to view the data , that definitely works better "in context" right next to the examples and explanations of the subject matter.
All in all, I'd give this book a 8 out of 10 rating. The only reason I wouldn't give it a 10 is the few errors that have been found in the book. (see above link). I actually noticed a couple myself. Nothing earth shattering, but none the less, for that alone it couldn't earn a 10 out of 10 mark. The book is an excellent companion to "Learning the Bash Shell", and if you liked that book, you'll love this one. Again, this isn't for those new to shell scripting, but is a great intermediate book. This will be a book that will have a permanent home on my bookshelf looking like an old phonebook, tattered and used. Isn't that the best sign of a great book ?
Book Review: Classic Shell Scripting,
September 09 2005
Submitted by
Dan Clough
[
Respond |
View]
Classic Shell Scripting
Hidden Commands that Unlock the Power of Unix
By Arnold Robbins, Nelson H.F. Beebe
First Edition May 2005
ISBN: 0-596-00595-4
558 pages, $34.95
http://www.oreilly.com/catalog/shellsrptg/
I found this to be quite a useful book for learning more about Unix/Linux shell scripting. I would consider this one to be an intermediate level text, and complete beginners might be better served by a more simplified book. There are quite a bit of in-depth details included, and many very nice examples and code snippets. Like all O’Reilly books, it is well organized and formatted, and clearly written.
The book opens with a brief history of Unix and how important the shell (and scripting) is to it. There are some comparisons with other programming languages, and why it is sometimes preferable to use a script versus a compiled program. The very basics of how scripts are written and used are also mentioned here, and beginners may want to refer to an additional book for more of the basic instructions.
The next few chapters cover mostly text processing with scripts, including searching, sorting, printing, extracting, and counting methods. Good examples are used, including the use of regular expressions and pipes to increase the power of your scripts. Following this, there are several chapters on more advanced scripting, including how to use variables, loops, functions, standard I/O, redirection, wildcards, using “awk”, and working with external files. Extensive example code is provided throughout.
The remaining chapters of the book get into more advanced subjects such as database manipulation, process control, and increasing the security of scripts. Portability and shells other than bash are also discussed.
Perhaps the most interesting part of the book (for me) were the Appendices and other sections at the end. Appendix A is entitled “Writing Manual Pages”, and is extremely informative on how to produce and format a valid man page. This is a much more complicated process than I had previously known (can you say “groff”?), and is quite interesting. For anyone who has ever complained about a poor man page, this will give you all the tools you need to write an improved version! J Appendix B has some excellent in-depth discussion about Unix files and filesystems, including attributes and permissions. Appendix C is a summary of important Unix commands for shell scripting, categorized by function, which is a good quick reference list. Following this, there is an excellent Bibliography that recommends related books for further reading. Finally, there is good Glossary and an Index.
Overall, I found the book to be excellent in it’s content and quality. I would recommend that a beginner also find a companion book to more gently introduce the fundamentals of shells and scripting, but this volume is excellent for the intermediate to advanced user. If you want to fully use the power of the Unix/Linux shell, this is a “must-have” book! Well done to the authors and O’Reilly Publishing.
Media reviews
"The authors provide a thorough explanation of how shell scripts can be used most effectively and be tuned to individual requirements. This is a valuable source of information about finding the right tool for any given task and how to put it to work."
-- Major Keary, PC Update
"O'Reilly's
Classic Shell Scripting is a comprehensive and detailed text. Extensive use is made of example code to illustrate the discussions, but it is neither a tutorial nor a collection of solutions to specific problems...The book is a valuable source of information about finding the right tool for any given task and how to put it to work."
-- Major Keary, book
"
Classic Shell Scripting sounds like one of those tomes that encourage narcolepsy in the bookstore, but that just shows were getting prejudiced in our old age. Instead, its a jazzy, practical and fascinating book that totally took us by surprise. Unlike most programming languages, shell scripts make extensive use of the built-in Unix commands--
grep,
tr,
xargs,
find,
sort, and more must be mastered to make competent scripts. As a result, this book is really a hands-on guide to becoming a Unix guru. We cant tell whether this was the original goal of the authors, but we dont care because this is a masterpiece we refuse to part with. Failing a fourth edition of
Unix Power Tools, this is as good as it gets. 10/10."
--Paul Hudson,
Linux Format, July 2005
"Robbins and Beebe have produced a book that is really good in a variety of ways: it is well-written; it is well-organized; it is full of worthwhile examples and instances; and the code is lucid and clear... I've been using a number of flavors of Unix and Linux for more than 25 years. I learned a lot from this book... This is an excellent book. Buy it now!"
--Peter Salus,
UnixReview.com, May 2005
"With the rise of languages like Java, with its cool widgets, someone unfamiliar with Unix might not realise that there is a type of programming proceeding quietly in the background. The shell scripting described by the book has been a mainstay of every Unix variant for years. The book shows how writing a short script can be used to handle a wide range of tasks. Enhanced by the simple syntax of most shells. Very easy to learn... The book's subject totally lacks any glamour. But a lot of actual work gets done in these scripts."
--Wes Boudeville, Amazon.com review, May 2005
Read all reviews