In this chapter, we move on to some more-complex processing tasks. The examples that we consider are each of general utility, yet they are completely different from one another, and are absent from most Unix toolboxes.
The programs in this chapter include examples of command-line argument parsing, computing on remote hosts, environment variables, job logging, parallel processing, runtime statement evaluation with eval, scratch files, shell functions, user-defined initialization files, and consideration of security issues. The programs exercise most of the important statements in the shell language, and give a flavor of how typical Unix shell scripts are written. We developed them for this book, and they have proved to be solid production tools that we use, and rely on, in our daily work.
Some programs support searching for input files on
directory paths, much like the Unix shell searches the colon-separated
directory list in
PATH for executable
programs. This makes it easier for users, who can refer to files by
shorter names and need not be aware of exactly where in the filesystem
they are found. Unix doesn’t provide any special commands or system
calls for finding a file in a search path, even though there is
historical precedent in other operating systems for such support.
Fortunately, it isn’t hard to implement a path search, given the right
Rather than implement a path search for one particular program, let’s write a new tool ...