UNIX Power Tools

Using the shell interactively is becoming a bit of a black art.
  • Authors: Jerry Peek, Tim O'Reilly and Mike Loukides

  • Publisher: O'Reilly & Associates

  • E-mail: info@oreilly.com

  • URL: http://www.oreilly.com/

  • Price: $59.95 US

  • ISBN: 1-56592-260-3

  • Reviewer: Samuel Ockman

The second edition of UNIX Power Tools is an impressive book by any measure. Numbering a hefty 1073 pages, it covers shells, editors and tools such as AWK, sed and RCS. The primary authors are Jerry Peek, Tim O'Reilly and Mike Loukides, but the book is made up of hundreds of individual articles by many different people, including UNIX luminaries Tom Christiansen and Simson Garfinkel.

UNIX Power Tools supplies many hints on how to save typing time by teaching you how to better use your shell interactively, how to take advantage of your editor and how to program scripts.

Using the shell interactively is becoming a bit of a black art. Luckily, UNIX Power Tools covers everything you need to know about this subject. Here are a few examples from the book to give you an idea of what it covers. First, here is how to edit three existing files: afile, bfile and cfile:

emacs [a-c]file

Many people already know how to do this; however, it works only if the files already exist. Lesser known is what to do if the files don't already exist. In this case, you edit all three at once by using:

emacs {a,b,c}file
With this information, it's easy to figure out how to make backup files:
cp filename{,.bak}
This command will copy the filename to filename.bak. Here's how to use this same idea to print six files or more:
lpr /usr3/hannah/training/{ed,vi,mail}/lab.{ms,out}
Are you confused by the find command? You won't have any problems after reading Chapter 17, which has 24 pages devoted to find. File permissions and processes are also covered in depth in their own chapters. Even wild cards get their own chapter. Whole chapters are also devoted to printing, terminal and serial line settings. (The book includes a great explanation of termcap and terminfo.)

vi is given two large chapters, while Emacs is relegated to being “the other editor” and given a scant ten pages. The vi coverage probably includes everything you'll ever need to know about it, while the Emacs section basically covers a few timesavers and the most essential commands, such as:

ESC-x psychoanalyze-pinhead

Missing from the book, though, is my favorite Emacs amusement:

ESC-9 ESC-x hanoi
The important thing to keep in mind is no matter what level of UNIX or Linux expertise you have now, you can learn much more. Some of the hints are beginner-oriented, but some may have even the most experienced user saying, “Hey, I never knew that...”

Here's a question for you. How do you run a program, while routing the standard error through a pipe to the mail program and leaving standard output on your screen under a Bourne shell? The answer is simple:

(program 3>&1 1>&2 2>&3 3>&-) | mail ockman &

Although bash and tcsh get special mention (as well as the more generic Bourne shell family and csh), the most powerful shell, zsh, is left out. Since so much of the book is devoted to shells, this is bothersome. Anyone who is really interested in having the most “power” will choose zsh. Still, since zsh is largely a superset of the other shells, almost all of the tips are still helpful.

sed is covered fairly extensively, and awk is covered sufficiently. Besides, in my opinion, all you need to know about sed and awk these days is that you use s2p and a2p respectively to translate your code to Perl. Speaking of Perl, the book has a few essays on why you should learn Perl, but offers no real help in doing so. It does offer the good recommendation of buying other O'Reilly books on the subject.

This book also does not cover networking or the X Window System, but that's good, because it leaves space for more important things. Nor, unfortunately, does it particularly make mention of Linux, although almost all information in the book holds true for Linux.

The book includes a CD-ROM of programs. Many of these programs are probably already installed on your Linux system, but you'll find quite a few others that will be useful. All of the programs are discussed in the text of the book. The CD includes source code and binaries for both Intel Linux and a handful of UNIX platforms. It does not make it clear which license the various programs fall under.

UNIX Power Tools is highly recommended. It's yet another amazing book from O'Reilly. After digesting all one thousand pages, you will be a wizard on the command line.

Samuel Ockman owns Penguin Computing (http://www.penguincomputing.com/). He spends all his free time rattling on about how great zsh is. His forthcoming book Super Advanced Programming in the Linux Environment is in the very early planning stages. You can e-mail him at ockman@penguincomputing.com.


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

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.

Learn More

Sponsored by ActiveState