Learning the Bash Shell, 2nd Edition

Authors: Cameron Newham and Bill Rosenblatt
Publisher: O'Reilly & Associates, Inc.
E-mail: info@oreilly.com
URL: http://www.oreilly.com/
Price: $29.95 US
ISBN: 1-56592-347-2
Reviewer: Bob van der Poel
The user shell is the most-seen and used program on any UNIX system. Through the shell, a user can type commands for file maintenance, launch various application programs, and automate tedious day-to-day system administration. Some computer systems (such as Windows 95) don't come with a shell, but Linux includes a multitude. Most Linux systems have csh, sh, tcsh, ksh and bash pre-installed. bash seems to have become the standard shell for Linux.
bash, an acronym for “Bourne again shell”, is a large, complicated and powerful program. It has been developed over many years and is intended as the standard shell for GNU systems. The GNU distributions of bash come with a manual page and info-style documentation. If you are familiar with UNIX shell programming, then those will probably be all you need to get bash to do what you want. On the other hand, if you've read the man pages a few times and are still scratching your head, you may need more help.
Learning the Bash Shell, as the authors summarize in their preface, “is designed to address casual UNIX and Linux users who are just above the raw beginner level. You should be familiar with the process of logging in, entering commands, and doing some simple things with files.” After reading the book a few times, I agree; however, the usefulness of this book goes beyond simply being a beginner's tutorial. If you haven't earned all the stars on your UNIX-wizard cap, you will find it an often-used reference.
Learning the Bash Shell is a 320-page book divided into eleven chapters, five appendices and an index. It is written in an easy-to-follow style which avoids, as much as possible, the terse style of man pages and jargon. The layout and typesetting make it easy to navigate though the various explanations and examples.
The first three chapters give an overview of the functions of a shell, the extensive command-line editing capabilities of bash and the setting up of a customized environment. The section on command-line editing is one I will read a few more times—the more I understand and begin to use bash's power, the less typing I do. Considering the state of my typing ability, this is a Good Thing.
The next five chapters are certainly the most valuable—they deal with actually programming bash. All the command words, variables and built-in functions are covered. Much of this expands on material in the man/info documentation, with additional comments on when you might want to use a particular command, its history, and in some cases the suggestion that you may never need to use it. Furthermore, most of the explanations are accompanied by examples showing exactly how and when to use the command and its arguments. In good pedagogical style, the authors present a simple example; then, as the reader learns more features, the examples are revisited and expanded until one has a useful and solid shell program. Suggested exercises are included for the reader to work on in order to improve programming skills.
If you've done any programming, you know about the tedious chore of tracking down bugs in your programs. Writing scripts in bash is no different—you will have bugs, and sometimes they will be hard to find. Actually, with the arcane syntax of shell scripts, they may be very hard to find. Chapter nine will help. The standard debugging methods (lots and lots of print statements) are covered, and an extensive debugger is presented by the author. The most interesting part of the debugger is that it is actually a bash script—neat.
The final two chapters deal with the rather mundane topics of installing bash as your user shell, some security issues, and obtaining and installing bash on your own system. Fortunately, since bash comes pre-installed as the standard shell on most Linux systems, this section can be skimmed through.
The five appendices contain the expected reference lists, BNF (Barkus-Naur Form) syntax, etc.—good, useful information. Finally, the 14-page index makes it easy to use the book as a standard desktop reference.
Learning the Bash Shell was written for the 2.x version of bash; however, any features which are not supported by earlier versions of bash are noted.
Programming in a shell language like bash is quite different from using a high-level language like C. To me, it seems that bash has been kludged together by a large number of individuals who, when adding needed features, merged their preferred syntax into the shell language. The result is that the bash language can be rather convoluted, and it is easy for a beginner to get bogged down in details. For this reason alone, Learning the Bash Shell is an important tool. Be aware that writing shell scripts, especially if you have root permissions, can be dangerous to the health of your system. Fortunately, the authors warn you when their examples can compromise system integrity or security.
The examples are short enough for the user to type in, and also available from O'Reilly's FTP site—well, the authors state they are. I followed the instructions in the book and downloaded the source file. Unfortunately, the file is for the first edition of the book and misses the entire debug script. I contacted O'Reilly by e-mail and received a courteous and timely reply advising me that they would contact the book editor to track down the source. Perhaps by the time this review is in print, the correct source will be available.
We have learned to expect professional, well-written, technically correct books from O'Reilly, and Learning The Bash Shell is no exception. Writing technical reference books is always a difficult task. It is even more trying when the knowledge base of the intended audience is as varied as the book's potential readers. I think the authors have succeeded in making both an introductory primer for new users and a valuable reference for the more experienced. I highly recommend this book to anyone who wants to become more productive using bash, as well as those who wish to learn to write moderately complex shell scripts.

Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Linux Systems Administrator
- Validate an E-Mail Address with PHP, the Right Way
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- Bought photoshop CS5 for developing a website :(
1 hour 53 min ago - What the author describes
3 hours 19 min ago - Reply to comment | Linux Journal
7 hours 30 min ago - Reply to comment | Linux Journal
8 hours 15 min ago - Didn't read
8 hours 25 min ago - Reply to comment | Linux Journal
8 hours 30 min ago - Poul-Henning Kamp: welcome to
10 hours 40 min ago - This has already been done
10 hours 41 min ago - Reply to comment | Linux Journal
11 hours 27 min ago - Welcome to 1998
12 hours 15 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Bash Programming
Nice bash tutorial at
http://www.gnulamp.com/bashprogramming.html
http://www.gnulamp.com/awk.html
awk tutorial at:
http://www.gnulamp.com/awk.html