A shell is a program that interprets your command lines and runs other programs. Another name for the shell is "command interpreter." This article covers the two major UNIX shells, including discussion about how shells run, how they search for programs, and how they read shell script files.
For each command it runs, a shell does a series of steps.
if the shell is reading commands from a terminal (interactively),
it prints a prompt (such as a
A shell can read command lines from a terminal or it can read them from
When you put command lines into a file, that file is called a
or shell program.
The shell handles the shell script just as it handles the commands you type
from a terminal (though it doesn't print the
In addition though, there are a number of programming constructs that make it possible to write shell programs that are much more powerful than just a list of commands.
As article 8.7 explains, if the shell is trying to run a command and the command isn't built-in to the shell itself, it looks in a list of directories called a search path . UNIX systems have standard directories with names like /bin and /usr/bin that hold standard UNIX programs. Almost everyone's search path has these directories.
If you do much shell programming, you should make a directory on your account for executable files. Most people name theirs bin and put it under the home directory. See article 4.2 .
Most serious shell programmers write their scripts for the Bourne shell. So do we.
Newer Bourne shells have features - like , an unset command for shell variables, and others - that the earlier Version 7 Bourne shell didn't. Most scripts in this book are written to work on all Bourne shells, though - for portability, the scripts don't use these new features.
For the rest of
these introductory articles,
it may be easier if you have a terminal
close by so you can try the examples.
If your account uses the Bourne shell or one of its relatives (
, etc.), your prompt probably has a dollar sign (