Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, how to do this:

$ job1 &
$ job2 &
$ wait $p1 $p2
share|improve this question
up vote 10 down vote accepted
job1 &
job2 &
share|improve this answer

If bash is your shell and you might stumble upon the following error, if you try to put all the statements into one line:

$ job1 & p1=$!; job2 & p2=$!; wait
-bash: !: event not found

The ! character invokes bash's history substitution. To get around this you need to add a space between the $! and the ;, like this:

$ job1 & p1=$! ; job2 & p2=$! ; wait
[1] 20198
[2] 20199
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.