7. Passing Arguments

In This Chapter

The shift Command

Exercises

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 runtbl 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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.