O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required