4. And Away We Go
Based on our discussions in Chapter 2, “What Is the Shell?,” you should now realize that whenever you type something like
who | wc -l
you are actually programming in the shell. That’s because the shell is interpreting the command line, recognizing the pipe symbol, connecting the output of the first command to the input of the second, and initiating execution of both commands.
In this chapter, you’ll learn how to write your own commands and how to use shell variables.
Command Files
A shell program can be typed directly, as in
$ who | wc -l
or it can be typed into a file and then the file can be executed by the shell. For example, suppose that you need to find out the number of logged-in users several times throughout the day. ...
Get Shell Programming in Unix, Linux and OS X, Fourth 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.