Chapter 7. Input/Output and Command-Line Processing
The past few chapters have gone into detail about various shell programming techniques, mostly focused on the flow of data and control through shell programs. In this chapter, we’ll switch the focus to two related topics. The first is the shell’s mechanisms for doing file-oriented input and output. We present information that expands on what you already know about the shell’s basic I/O redirectors.
Second, we zoom in and talk about I/O at the line and word level. This is a fundamentally different topic, since it involves moving information between the domains of files/terminals and shell variables. print and command substitution are two ways of doing this that we’ve seen so far.
Our discussion of line and word I/O then leads into a more detailed explanation of how the shell processes command lines. This information is necessary so that you can understand exactly how the shell deals with quotation, and so that you can appreciate the power of an advanced command called eval, which we cover at the end of the chapter.
I/O Redirectors
In Chapter 1 you learned about the shell’s
basic I/O redirectors, <
, >
, and |
. Although these are enough to get
you through 95% of your Unix life, you should know that the Korn shell supports a
total of 20 I/O redirectors. Table 7-1 lists them, including the three we’ve already seen. Although some of the rest are useful, others are mainly for systems programmers. We will wait until ...
Get Learning the Korn Shell, 2nd 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.