Chapter 7. Passing Arguments

Shell programs become far more useful after you learn how to process arguments passed to them. In this chapter, you'll learn how to write shell programs that take arguments typed on the command line. Recall the program run that you wrote in Chapter 5, “And Away We Go,” to run the file sys.caps through tbl, nroff, and lp:

$ cat run
tbl sys.caps | nroff -mm –Tlp | lp

Suppose that you need to run other files besides sys.caps through this same command sequence. You could make a separate version of run for each such file; or, you could modify the run program so that you could specify the name of the file to be run on the command line. That is, you could change run so that you could ...

Get Unix Shell Programming, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.