In this section we introduce the basic building blocks used in just about all shell scripts. You will undoubtedly be familiar with some or all of them from your interactive use of the shell.
The shell's most basic job is simply to execute commands. This is most obvious when the shell is being used interactively: you type commands one at a time, and the shell executes them, like so:
cd work ; ls -l whizprog.c-rw-r--r-- 1 tolstoy devel 30252 Jul 9 22:52 whizprog.c $
These examples show the basics of the Unix command line. First, the format is simple, with whitespace (space and/or tab characters) separating the different components involved in the command.
Second, the command name, rather logically, is the first item on the line. Most typically, options follow, and then any additional arguments to the command follow the options. No gratuitous syntax is involved, such as:
Such command languages were typical of the larger systems available when Unix was designed. The free-form syntax of the Unix shell was a real innovation in its time, contributing notably to the readability of shell scripts.
Third, options start with a dash (or minus sign) and consist of a single letter.
Options are optional, and may require an argument (such as
Options that don't require an argument can be grouped together: e.g.,
ls -lt whizprog.c rather than
ls -l -t whizprog.c ...