Features
- Cover Type: Paperback with 512 pages
- Published by: Sams
- Edition: 1st Edition December 1, 1989
- Written in: English
- ISBN 10 Number: 067248448X
- ISBN 13 Number: 978-0672484483
-
Book Dimensions:
9.1 x 7.4 x 0.8 inches
- Weighs: 1.9 pounds
Book Description
UNIX Shell Programming, Revised Edition, shows UNIX users how to quickly and easily automate routine tasks by taking command of the UNIX shell. The shell makes light work of big tasks by transferring your simple instructions into powerful commands that put UNIX through its paces. You don't have to be a programmer, or a UNIX expert, to use shell programming to take control of your environment--if you are acquainted with UNIX, this book can take you the rest of the way. If you are a programmer, you'll be surprised at the range of tasks you can automate with the shell--and at the speed and convenience the shell has over many high-level
programming languages. If you're from the growing ranks of UNIX system administrators, this book shows how the shell can make your life easier while improving your service.
- Complete instructions for the standard or "Bourne" shell, plus the "Korn" shell, destined to become the shell of choice
- Many complete, practical programs and accompanying exercises to help you understand, remember, and check your progress
- Simple, step-by-step tutorials that lead you through writing real shell programs
Reader Reviews
Although published in 1990, this book could still function well as an introduction to UNIX and (Bourne) shell programming, provided one is aware of some changes to the shell in most implementations of UNIX since that date. Also, the Perl language has come on strong in recent years, and depending on your tastes (and time), that language can be used with great efficiency to do the tasks that are traditionally done in the shell. After a quick review of the basics of UNIX, the authors give a purely descriptive explanation of the UNIX shell in chapter 3. Emphasizing that it is an interpretive language, the most commonly used shell commands are discussed in chapter 4, starting with a discussion of regular expressions. The cut, paste, sed, tr, grep, uniq, and sort commands are treated in detail. In chapter 5, one begins the actual task of creating shell programs using shell variables. There is no data typing in the shell, so values can be assigned to variables without noting their type as integer, float, etc. The authors only briefly discuss the mechanism in shell programming. The method by which the shell interprets quotation characters is covered in the next chapter. The single, double, backslash, and back quote characters are discussed in detail. Noting that arithmetic operations are done on values stored in variables in the shell, the authors show to proceed with these operations using the expr program. The mechanisms for passing arguments to shell programs is treated in chapter 7, the authors showing how to write shell programs that take arguments typed on the command line. The role of positional variables for delaying assignment after normal command line processing is discussed. The $#, and $* variables are discussed briefly, with $# getting set to the number of arguments typed on the command line and $* used for programs taking a variable number of arguments. The shift command is explained well as a method to allow one to use more than nine arguments to a program. The ability of shell programs to execute decision blocks is treated in chapter 8, via the if statement. The role of the test and exit commands are in if blocks are discussed in good detail. In addition, the case command, familiar to C programmers is introduced as a technique to allow a single value to be compared against other values. The && and || constructs are used to show the reader how to execute commands that are contingent on the success or failure of the preceding command. Program loops, via the for, while, and until commands are discussed in chapter 9, followed in the next chapter by a discussion of how to read data from the terminal or from a file using the read command. The ability to perform I/O redirection is discussed also. Local and export variables are discussed in the next chapter on the user environment, and the authors give a good summary of how these work in shell programming. More discussion on parameter passing is done in chapter 12, with the different methods of parameter substitution given detailed treatment. The authors show how to use the $0 variable to check whether two or more programs have been executed, and how to use the set command to set shell options and to reassign positional parameters. This is followed in the next chapter by a discussion of the eval command, which makes the shell scan the command line twice before executing it, and the wait command, which will allow serialization in program execution. The trap and type commands are discussed also. The Korn shell is discussed in chapter 15, with emphasis on the features added to Korn shell that cannot be found in the Bourne shell. The vi and emacs capability of this shell is briefly discussed in this chapter. The differences between Korn shell functions and Bourne shell functions are discussed in detail by the authors. Most importantly, the ability of the Korn shell to do integer arithmetic without using the expr command is discussed via the let command, which is built-in to the Korn shell. Also, the capability of the Korn shell to support data typing is discussed, along with its pattern matching capabilities. Pattern matching is done most efficiently now using Perl however.
Comment | |
(Report this)