Jump to ratings and reviews
Rate this book

Linux Shell Scripting Cookbook

Rate this book
Linux Shell Scripting Cookbook

360 pages, Paperback

First published January 16, 2011

7 people are currently reading
118 people want to read

About the author

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
7 (18%)
4 stars
13 (35%)
3 stars
12 (32%)
2 stars
4 (10%)
1 star
1 (2%)
Displaying 1 - 7 of 7 reviews
Profile Image for Pierre Sugar.
1 review
June 24, 2013
I have started using Linux in 2000 with Suse Linux. Coming from Windows Linux right away took my interest especially the tremendous freedom it gives you and the ability to operate the system instead of being operated by the system. But if you want to get into the depth of Linux and being an expert the learning curve especially when starting is quite steep and the huge amount of possibilities is hard to tackle. But if you go over this hurdle than you get rewarded with the knowledge of how to rule your computer. You can do it the hard way as I did when starting with Linux by asking Google for each and every question coming up. But if you want to accelerate to get into understanding and using Linux not only on the surface than this book is for you: Linux Shell Scripting Cookbook - Second Edition.

The book is precisely focused on shell scripting and is therefore allways right to the point. So you won't find information on how to install Linux but as this is one of the easier parts you can find a lot of good information on the internet and nowadays setting up a Linux machine is quite easy.

If you have Linux installed this book helps you to jump right into the topic. In the introduction of chapter 1 you get the basics about the shell environment you need just enough to start scripting. For example it is explained what does the prompt look like, the structure of a shell script and how to start it. And some handy information to avoid unnecessary typing using the history.

After the introduction of each chapter the book starts with recipes. Each recipe is introduced with a short objective of a recipe and then it has more or less always the same structure. Getting ready gives a brief overview of the commands and syntax used in the following sections. How to do it shows how the commands are used that support the objective. The explanation is done on practical and real life examples that can be used in your day to day work. In some recipes you get also deeper information in the But there is more section that can be skipped at a first read and referenced later when topic comes up in combination with other recipes.

As this book's title denotes the content is presented as a cookbook. In a cookbook you can assume to jump into a specific topic and than just program along. But I would recommend before starting to read the first chapter as it explains all basic elements of a shell script like variable assingment, arrays, functions and other programming structures as well as debugging tools and strategies. After chapter 1 you have enough information to tackle the recipes in following chapters.

Chapter 2 and chapter 3 provide a comprehensive set of recipes on file manipulation. Chapter 2 is more focused on recipes you will need in your day to day work, like finding, copying and moving files. Chapter 3 has more sophisticated recipes like file comparisson to find out the differences between two files.

Chapter 4 is about the content of files, that is finding and manipulating the content of a file. The chapter starts with an introduction into regular expressions and some often used patterns like e-mail address validation are provided.

Especially interesting to me was chapter 5 which goes beyond the Linux operating system but shows how to use shell scripting for accessing the web. I liked the recipe about cURL, a very sophisticated and comprehensive tool for accessing the web through a lot of different web protocols. This recipe gives you a kick start into cURL with the commands you will use 80% of your time when down or uploading files from or to the web or another file system.

The book does not only cover topics you would need as a regular Linux user but also provides recipes for administration tasks. And from my experience the book covers the main commands that you would need to administer your private Linux home network to keep it up and running. The chapters 6, 8 and 9 cover backup tools, tools for monitoring you system and manipulating or running automatically scheduled processes with cron jobs.

And finally chapter 7 has a lot to say about setting up a network. The topics cover file transfer between computers or logging in to remote computers using ssh.

If you are a programmer of a programming language that uses a lot the Linux shell like Python, Ruby or Ruby on Rails than I also can recommend this book. It covers the topics you will need when mainly working with the console and not using an IDE. Especially useful I consider in this regard the topics how to find files, how to compare files, how to find a specific content of a file that you need to refactor. SSH without login is also very useful when working with Ruby on Rails and administrating an application server like passenger. Also the brief introduction into Git serves as a good start into managing and archiving your source files like the scripts you generate based on the knowledge gained from the book. The section finding broken links on a web site is very helpful when working as a web developer.

So all in all this book is a very helpful companion whether you are using Linux as a regular user or as an administrator. And if you are a developer you find a lot of valuable commands and recipes that make your programming life easier. It is a book you should have handy when you are one of the above mentioned users to make your life easier with Linux.
1 review
June 23, 2013
The main challenge in learning Linux shell scripting is the "tyranny of choice". A standard Linux shell gives you access to hundreds of commands. Some commands are very popular and generally useful while some are quite esoteric. Learning all these commands would take a lot of time and is counter productive. So when learning the Linux shell, one is faced with the question of which commands to learn. Aside from the hundreds of commands, Linux commands, especially the most useful ones, have lots of options. Most of the time, one could be productive by learning only the commonly used options. So because of the large number of choices when learning the Linux shell, a linear approach of learning the commands and the options one by one would not be practical.

The Linux Shell Scripting Cookbook uses a problem-based approach instead of the answer-based approach. It starts with what you want to do and provides the solution. How to do it; which commands to run and the options that goes for each command. It also discusses variations of the solutions. Learning in this manner, in my opinion, is a perfect fit for learning the Linux shell. It eliminates the need to make choices on what commands and option to learn. You determine what you need to do, look at the solution and eventually build a set of commands and options based on your needs. Thus, making you productive right away. After learning a set of commands, you'll be able to better judge which commands are more useful to you and can pursue to master those commands. In my case, I realised that I would be more productive with a deeper understanding of sed and awk.

Aside from being a very good starting point to learn the Linux shell, the cookbook approach also serves as a very good reference. Had the book used the answer-based approach, content is organised by commands, you would have to figure out which commands would probably be applicable to your problem.

My favorite chapter in the book which I always keep coming back to is chapter 4, "Texting and Driving". Every now and then, I have to process data in text files and because the discussion of sed, awk, grep, and regular expressions in this chapter is concise and focuses on what is most useful, I could afford to do a quick read of the topics, before I start working. I noticed that the use-cases tackled are quite close to what I often need to do.

All things considered, I highly recommend this book to beginners and intermediate users of the Linux shell. However, I think the title of the book can be quite misleading. At first, I thought that the book was only useful to learn shell scripting, but it is also very useful as a Linux command reference.
Profile Image for Julio Biason.
199 reviews28 followers
February 22, 2016
I don't know why, but when I saw the title, I expected to be a book only about bash. Bash is a shell for *nix based systems and, as VIM, is one of the apps you can use for 10 years and, after reading something about it, you find something completely new.

Thing is, this is not just about bash. This book is about tools in the GNU system that can help write shell scripts. And even if you're pissed about Stallman asking to call the system GNU/Linux, this *is* about GNU tools: tr, expect, find... All GNU tools.

So "GNU Shell Scripting Cookbook" would be a more appropriate title.

About the content itself... It's mostly a miss than a hit. Some things are some wrong it hurts (Git does *not* add a `.git` directory inside every directory) and some are so utterly stupid to the point of being dangerous (you don't need root to chown a file!). Some points are so strange, they seem like the authors used a GNU/Linux for only two months and decided to write a book about it.

The book have two authors and it shows. Lots of repeated information, some things not building on things already said (really guys? Not matching pipe with stdin/stdout redirection?) will give you the impression that they never spoke about the book or had a roadmap for it. And there is a shitton of "as follows" (seriously, you'll get sick of reading "as follows" over the book). It says in the cover that, besides the two authors, there were at least 5 reviewers. But it seems none of them actually read the book -- and I'm not talking about easy things to find in a 1 minute Google search (like the git thing), but things like "this 'as follows' is getting through my nerves, you're using it every-fucking-where".

The content gets better in the end, when it gets over the "teaching phase", but you'll still have the bad taste of things wrong from the previous chapters.

So, basically, the book tries to cater to two different audiences -- the beginner and the master -- and doesn't seem to be able to provide a good content for any.
Profile Image for Jascha.
151 reviews
March 1, 2015
This is a good book for all the beginners to intermediate Linux power users and system administrators out there. Easy to read, being a cookbook it allows the reader to freely jump directly to the subjects of interest without having to pass through all the previous recipes. DevOps could also find this useful, mainly if they are interested in strengthening their Bash skills to ease cloud deployment.

As stated above, this is a cookbook, not an introductory text to convince the reader to leave Microsoft and embrace the penguin, nor to get him started, step by step, with his favorite distro. No, this is a cookbook, a collection of independent recipes for all those that already use Linux on a daily basis and want to get the most out of their Bash shell.

Linux Shell Scripting Cookbook is divided into 9 chapters, summing up 110 recipes, most of which are clever one liners that you want to take note of. The very end of the book, which covers topics that will probably interest more system administrators rather than home users, has, instead, complex scripts and focuses on networking, monitoring and logging.

I must admit that some command such as tr, sort and logrotate, commands that I reckon as must know, should have been given more space and examples. On the other hand, instead, others, such as ps, were given way too many pages.

Concluding, Linux Shell Scripting Cookbook is a good book. Not great, but good. Certainly a good companion for anyone interested in unleashing the power of the Bash shell.

As usual, you can find more reviews on my personal blog: http://books.lostinmalloc.com Feel free to pass by and share your thoughts!
1 review1 follower
June 23, 2013
The book is organized into 9 chapters which contain recipes to demonstrate real-life usages of shell scripts. It starts with basic Bash topics (simple commands like echo, environment variables, the prompt, redirection) in the first chapter. Then we have some more advanced
commands like tr, cryptographic hashing commands and more in the second chapter. The third chapter deals with files and filesystems and handy scripts which are related: working with file permissions, printing the directory tree, finding and deleting duplicate files, and more. The other chapters deal with text utils, web scripts, networking, monitoring and logging, and administration tasks.
The book contains over 110 practical recipes; in these recipes, the authors
define a task and present a Bash script to achieve it. In many cases they
expand on it (in sections titled "How it works..." or "There's more..."). I find this way of presentation very efficient and clear.
In summary: the book is written well and easy to read, and is based on many practical, straight forward examples which can be used by many for daily tasks. One of its great advantages is it that it covers a wide range of topics. The book will be helpful for beginners and intermediate and is good to have near your desk.
Profile Image for Lewis Lacook.
Author 6 books8 followers
March 20, 2015
It's poorly written, but the information presented is crucial to basic Linux System Administration.
Displaying 1 - 7 of 7 reviews

Can't find what you're looking for?

Get help and learn more about the design.