Mar 9, 2013

How can one run multiple programs in the background with single command?

The bash manpage section titled Compound Commands has two options that would work, list and group commands.

A group command is a series of commands enclosed in curly braces {}. A list is the same, enclosed in parentheses (). Both can be used to background multiple commands within, and finally to background the entire collection as a set. The list construct executes commands in a subshell, so variable assignments are not preserved.

To execute a group of commands:
{ command1 & command2 & } &

You can also execute your commands in a list (subshell):
( command1 & command2 ) &

Note that the list () syntax executes the enclosed commands in a subshell, so variables are not preserved within.

No comments: