## Command Grouping

Sections of shell input lines can be enclosed in parentheses which permits modifiers and separators to be applied to an entire set of programs. The shell processes them by calling itself recursively (as a new process) to execute the enclosed program list. For example:

    OS9: (dir /d0; dir /d1) >/p

gives the same result as:

    OS9: dir /d0 >/p; dir /d1 >/p

except for the subtle difference that the printer is “kept” continuously in the first example; in the second case another user could “steal” the printer in between the dir commands.

Command grouping can be used to cause a group of programs to be executed sequentially, but also concurrently with respect to the shell that initiated them, such as:

    OS9: (del file1; del file2; del file3)&

A useful extension of this form is to construct pipelines consisting of sequential and/or concurrent programs. For example:

    OS9: (dir CMDS; dir SYS) ! makeuppercase ! transmit

Here is a very practical example of the use of pipelines. Recall that the dsave command generates a procedure file to copy all the files in a directory. The example below shows how the output of dsave can be pipelined to a shell which will execute the OS-9 commands as they are generated by dsave. Assume that we want to copy all files from a directory called `WORKING` to a directory called `ARCHIVE`:

    OS9: chd /d0/WORKING; dsave ! (chd /d0/ARCHIVE)