6.3. Grouping commands using () and {}

To run several commands as a group effort all at once, the shell provides two methods. You can either run the group in the current shell or in a subshell.

To run a list of commands in the current shell, separate each command with a command separator, and enclose the list with round brackets.

The general format is:

(command1; command2; . . ) 

To run a command in the subshell do exactly the same but use {} instead of (). The general format is:

{command1; command2; . .) 

I do not use these methods by themselves very often. The only time I use these grouping operators is in conjunction with the && or ||.

Going back to our comet script example, if the script comet failed I would probably want to execute two ...

Get Linux and Unix Shell Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.