Jump to ratings and reviews
Rate this book

Shell Scripting Recipes: A Problem-Solution Approach

Rate this book
*Author is active and well-known within the community *Comprehensive and example-driven, for faster completion of administration tasks *Scripts are POSIX-compliant; supported by all mainstream shells *All examples contain the problem, the solution, and the code needed to implement the solution.

448 pages, Paperback

First published January 1, 2005

1 person is currently reading
31 people want to read

About the author

Chris F.A. Johnson

3 books1 follower

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
3 (25%)
4 stars
4 (33%)
3 stars
4 (33%)
2 stars
1 (8%)
1 star
0 (0%)
Displaying 1 of 1 review
422 reviews85 followers
July 6, 2016
I had a cursory understanding of shell scripting, so I wanted something that would fill in some of the blanks. I didn't expect one book to take me from total beginner to extremely-skilled, but I feel like that kind of happened with this book. I used to think shell scripting was wimpy, while Python, Perl, and Ruby are more appropriate for heavy-duty scripting, but this book shows just how incredibly powerful it is when doing anything relating to processes and file system. After reading this book, I've found myself just always writing shell scripts for everything and dropping the other scripting languages entirely. It just allows me to express things so much more directly.

There are techniques and tools that advanced scripters reach for incessantly, such as AWK, parameter substitution, tweaking the IFS variable, && and ||, and overriding positional parameters. Really the best way to become a skilled shell scripter isn't to merely know about these techniques (I already did), but to see them used constantly and cleverly to solve tough problems elegantly and concisely. By the time I was even just halfway through this book, I had these things down cold because I'd read hundreds of pages where I saw them used to solve one problem after another. Then I started using them myself, and they made my life so much easier. By the time the book was done, it was all old hat!

I also appreciated the special attention the authors paid to performance. Some people think you relinquish all rights to fast code the second you step into shell scripting land, which is a shame because they just give up trying to optimize. This book was very careful about the performance of their scripts. They explained different techniques they used, and explained in comments that they did it that way because it performs better.

Something else that's interesting about this book is that it builds a shell scripting library as it goes along, which means it also doubles as a general purpose library. It then leverages this library in scripts later in this book. Building up a toolbox like this is a good approach to programming, and it's nice this book encourages that. The down side, of course, is that the recipes don't stand on their own. You need to refer back to other chapters to see where some of the used commands came from.

I don't have much to gripe about this book, but here's a few nits. For one, this shouldn't be a book about Bash, but shell scripting. It makes sense to assume Bourne shell rather than C shell, but Bash should not be assumed. There should be no Bashisms in the code, and this book follows that rule most of the time. There were some mentions of more elegant ways to do things if you have Bash, which was fine, but then the database chapter was a Bash-only chapter, with no mention of this fact.

Something I'd have liked to see in this book is a better explanation of the problems with quoting. This is the biggest bugbear of scripting for most beginners. Of course, this book is purposely light on explanation and heavy on examples.

This book is a little dry, and some of the examples are extremely narrow in the problems they solve. For example, there's a whole chapter just for scripts that help solve crossword puzzles, because one of the authors enjoys crosswords. I had the feeling they had hundreds of personal scripts they'd written over the years, and just decided to gather them all into a book. Unlike many other recipe books, this isn't a collection of techniques for solving common programming problems, but a bunch of entire scripts and functions to solve specific problems and general problems. Maybe it makes sense to do that for shell scripting, since most scripts are so short anyway.
Displaying 1 of 1 review

Can't find what you're looking for?

Get help and learn more about the design.