Online Book Reader

Home Category

Classic Shell Scripting - Arnold Robbins [5]

By Root 820 0
This is done on purpose, to allow vendors to support historical behavior as extensions, i.e., additional features above and beyond those documented within the standard itself.

Besides just telling you how to run a particular program, we place an emphasis on why the program exists and on what problem it solves. Knowing why a program was written helps you better understand when and how to use it.

Many Unix programs have a bewildering array of options. Usually, some of these options are more useful for day-to-day problem solving than others are. For each program, we tell you which options are the most useful. In fact, we typically do not cover all the options that individual programs have, leaving that task to the program's manual page, or to other reference books, such as Unix in a Nutshell (O'Reilly) and Linux in a Nutshell (O'Reilly).

By the time you've finished this book, you should not only understand the Unix toolset, but also have internalized the Unix mindset and the Software Tools philosophy.

* * *

[1] Throughout this book, we use the term Unix to mean not only commercial variants of the original Unix system, such as Solaris, Mac OS X, and HP-UX, but also the freely available workalike systems, such as GNU/Linux and the various BSD systems: BSD/OS, NetBSD, FreeBSD, and OpenBSD.

[2] This approach was popularized by the book Software Tools (Addison-Wesley).

[3] A 2004 edition of the standard was published after this book's text was finalized. For purposes of learning about shell scripting, the differences between the 2001 and 2004 standard don't matter.

[4] A technical frequently asked questions (FAQ) file about IEEE Std. 1003.1-2001 may be found at http://www.opengroup.org/austin/papers/posix_faq.html. Some background on the standard is at http://www.opengroup.org/austin/papers/backgrounder.html.

What You Should Already Know

You should already know the following things:

How to log in to your Unix system

How to run programs at the command line

How to make simple pipelines of commands and use simple I/O redirectors, such as < and >

How to put jobs in the background with &

How to create and edit files

How to make scripts executable, using chmod

Furthermore, if you're trying to work the examples here by typing commands at your terminal (or, more likely, terminal emulator) we recommend the use of a POSIX-compliant shell such as a recent version of ksh93, or the current version of bash. In particular, /bin/sh on commercial Unix systems may not be fully POSIX-compliant.

Chapter 14 provides Internet download URLs for ksh93, bash, and zsh.

Chapter Summary

We recommend reading the book in order, as each chapter builds upon the concepts and material covered in the chapters preceding it. Here is a chapter-by-chapter summary:

Chapter 1

Here we provide a brief history of Unix. In particular, the computing environment at Bell Labs where Unix was developed motivated much of the Software Tools philosophy. This chapter also presents the principles for good Software Tools that are then expanded upon throughout the rest of the book.

Chapter 2

This chapter starts off the discussion. It begins by describing compiled languages and scripting languages, and the tradeoffs between them. Then it moves on, covering the very basics of shell scripting with two simple but useful shell scripts. The coverage includes commands, options, arguments, shell variables, output with echo and printf, basic I/O redirection, command searching, accessing arguments from within a script, and execution tracing. It closes with a look at internationalization and localization; issues that are increasingly important in today's "global village."

Chapter 3

Here we introduce text searching (or "matching") with regular expressions. We also cover making changes and extracting text. These are fundamental operations that form the basis of much shell scripting.

Chapter 4

In this chapter we describe a number of the text processing software tools that are used over and over again when shell scripting. Two of

Return Main Page Previous Page Next Page

®Online Book Reader