Command1; command2

A command line can consist of multiple commands. Each command is separated by a semicolon, and the command line is terminated with a newline. The exit status is that of the last command in the chain of commands.

The first command is executed, and the second one is started as soon as the first one has finished:

    $ w; date

Output:

    $ w ; date > whoandwhen

Output from the date command will be redirected to the whoandwhen file.

In the preceding example, we can see that when we put multiple commands on the same line, but separated by the ; command, then those commands execute sequentially one by one:

    $ date; who am i
    Tue Mar ...

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.