O'Reilly logo

Shell Programming in Unix, Linux and OS X, Fourth Edition by Patrick Wood, Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required