We recently had a chance to review this fun book from No Starch Press called Wicked Cool Shell Scripts. Below is my brutally honest review, and thoughts regarding how this could be used in my regular work. This could also be a great book to include in High School Homeschool coding curriculum.
Wicked Cool Shell Scripts Book Review
First a couple disclosures
1. I cut my teeth on DOS. Version 2.something. I got a copy of 3.3 in High School. I stayed with that until getting Windows (for Workgroups) 3.11 in the early 90’s, then ’95, then ’98 SE… then XP sometime in 2005. I’ve worked on Microsoft-based OS’s for about 30 years. In the past few years, I switched my personal computer to Ubuntu. I’ve dabbled with Linux – DABBLED – since about ’96, and have worked on various Unix-y systems since then. On occasion. Until lately.
My point is this: I’m comfortable at a Command Line, but have never had to learn the myriad of utilities on a *nix system. I know enough to get my way around a system, ironically know more details about the various File Systems on a *nix box than I do the utilities, even the “standard” one. So CLI, Yes, but *Unix* CLI, only enough to limp around. I have to look up many typical things because I don’t do them often enough to remember the convoluted or non-obvious switches and options; e.g., finding a file named with something, or containing something. I know the obscure options on DOS commands because I had to, had no choice back in the day. Modern *nix systems? Not so much.
2. I discovered Python about 15 years ago and have never looked back. It’s my go-to for anything beyond browsing a file system. Yeah, even multiple file management. It’s easy-breezy beautiful to me.
My Observations Of The Wicked Cool Shell Scripts 2nd Edition:
- I was looking forward to reading this book to help me get a bit more comfortable with *nix CLI commands and Bash Scripts versus DOS Batch Files. That was my mindset as I started reading. All this to give perspective on what follows…
- I enjoyed the tone and style greatly; I found it pleasurable reading. The topics covered a wide range of interaction with data and file/data management, including The Outside World, via Internet utilities. Nice.
- But overall the book seemed confused about what it was. Was it a tutorial on BASH Scripting? No. Except where it was. Which, frustratingly, was more often than not detailing bits of the code that was uber-obvious. Except for the refreshing occasion where the text was pointing out a golden nugget of non-obvious code, how it worked, why IT was chosen as the solution. Was it chock full of ready-to-deploy useful tools and utilities for, say, Systems Management? No. Some hints, some mildly fleshed out ideas and concepts left to the reader to hack away at later. Which is cool and all. But, then, what IS the book about/for?
- This book would be a PERFECT use of time or money for anyone who *already* knows Bash Scripting in detail, and the more-common utils utilized in that pursuit, yet still doesn’t have a clue *what* to do with that knowledge. But who are we kidding? Who, exactly, is that audience? Who knows the fundamentals of Bash, yet has never been in an environment to utilize them, thus needs a book of spells to get the creative juices flowing?
- For someone getting started with Bash/scripting, this book could have been a great resource. It’s in that vein I give my critiques below. Again, I enjoyed this book immensely, but found it to be wanting/incomplete. And as the 1st Edition was a best-seller, and I sincerely hope this 2nd Edition will be as well, perhaps I am missing the forest for the trees; others seem to have “gotten it” well enough.
My Brutal Honest Critiques:
1. As I mentioned, Bash/Unix, at a CLI-level, isn’t yet a comfortable 2nd home to me. After starting to work through this book, a curiosity struck me that has a number of other times in my learning over the years: Why does one sometimes need to invoke things with “./myscriptname” instead of simply “myscriptname”? This book is mute on the matter. It indicates doing so, but not explicitly why. I researched the issue again – which takes a bit of Google Fu as we’re dealing with punctuation here – and had an “Oy, yeah…!” moment. The simple answer is this: For sanity/security purposes, Unix-like systems will ONLY execute commands/executables along one’s Path; it will NOT execute something in the current (“working”) directory, unless one is in a directory along the Path. As I Mentioned Squared, coming from DOS this is non-obvious. Just learning *nix even not knowing DOS, this would be non-obvious unless already told explicitly. I don’t think I’d be the only person reading this book who could use this tidbit. And then tie it all up in a bow with suggesting one makes a “My Utils” folder and adding that to the path; this concept is more-or-less laid out, but not as completely or plainly as I think would be (more) helpful. (The way it’s described, *I* could follow, but it was still a bit confusing to me. And I understood what was being discussed. How would it be for a “n00b”?)
2. Chapter 0, A Shell Scripts Crash Course, answers a number of basic questions. It seems to presume a rather green/new user to the quest of Becoming A Unix God, with some brief intros to some helpful commands. It answers the *what* about Shell Scripts. But the obvious – to me – is lacking: The basics of HOW to program in Bash Script Language. The verbiage is rather obvio”us to simply glean from the code throughout the book, but I have an advantage: *I* have started down the Bash Scripting path (and stopped) numerous times over the past 20 years. If-blocks starting with “if” and ending in the bemusing “fi”, for example. But I keep coming back to the same thought: If one is familiar enough to “get” these scripts, wouldn’t one be sophisticated enough that this book would be unnecessary?
3. As various common, standard utilities are introduced, it would be nice to have a brief description of it, and even more appreciated would a recommended “this would be a good website to get started with this in more detail” link. A third appendix with a compilation of all of these even nicer still. To my mind, this goes to the schizophrenic nature of this book: Is it, or is it not, some sort of intro text? And some might argue/defend by saying it’s decidedly not an intro to anything book. But then at times it seems to sincerely try to. To my point, sed and awk are used from the beginning, but only well into the book is awk described – indirectly, even – as Yet Another Scripting Tool (that’s presumably easier/more powerful than trying to use pure Bash to do); sed is never explicitly OR implicitly introduced, but one can presume it, at least, can do regex functions. (Oh, and what’s a “regex” would be great to introduce, too! Sure, *I* know, but will most Dear Readers…?) Then take something like lynx. *I* knew what it was before reading this book, but had never actually utilized it in any tangible way. My point is, lynx wasn’t just used, it was talked about at some length. So I ask: What does this book aspire to be? A Recipe Book, or a (How To) *Cook* Book? Relatedly, in general, I often was wanting more help/details about certain parts of code, and left wondering why other parts that seems obvious were described at length. For a specific example, the notion that blocks invoke [or at least act like] subshells and can be fed as such [pg 98] was very cool to learn about! On page 111, talking about sym/hard links, a bit more detail would have been nice, as well as at least a brief reason given for “We prefer symbolic links.” Or just don’t mention them at all, other than just a “In order for this action, do this. Then it will work.” kind of thing. My 2 cents. #YMMV.
4. Finally, my least-fair critique: Why this book at all? Why not just write the same thing using Python, instead? The code would be simpler and clearer. It would be more easily cross-platform. (One may install Py without joining some Super Secret Micro$oft Club. WHY, M$, WHY? Just let people download your Bash Abomination, why won’t you? Why the gratuitous hoops? Can you just not help yourself even when you’re TRYING to play nice with the other kids?!) To me there’s no easy answer. One *could* try the notion that “If you’re on a system where you can’t install software…” But that doesn’t work. Repeatedly the utils needed for the next script may/probably/definitely requires a download/install. So there’s no excuse to NOT (also) install Py. And then we’re back to the easier/more-powerful code tool. Some scripts were self-admitted glorified wrappers for awk scripts. One could even wonder why not just do everything in awk, and instead make this an awk book. (I don’t know if there’s an answer; “best tool for the job”-thing, and awk doesn’t work easily with external utils, where Bash… that’s precisely what it’s all about?)
I am very thankful for having the opportunity to read this book. Like I said in the beginning, I really enjoyed *reading* it. I just think a few additions would make it a much more valuable book – certainly to me, and I can’t see how it wouldn’t be for other readers as well. As it stands, I would recommend this book as supplemental material for someone just now learning Bash, but I’m not sure how much value it would have for someone who doesn’t need the additional help/info I mention, above. If you are interested in checking this book out, here is our affiliate link for Wicked Cool Shell Scripts 2nd Edition.