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

I want to do the following from the tcsh command line, preferably in 1 line:

build_cmd1 &
build_cmd2 &
build_cmd3 &
wait until all parallel build commands finish

That is, I want to fork off a bunch of build commands, block until they exit, and then run another command. I want to do this from the tcsh command line.

share|improve this question
up vote 4 down vote accepted

::checks with the man pages::

It looks like csh and derivatives support wait, so consider something like

% cmd1 &; cmd2 &; cmd3 &; wait; thing_to_do_after

or because the && and || operators short-circuit you could use

% (cmd1 &; cmd2 &; cmd3 &) && thing_to_do_after

but only if you are certain of the exit state of the subshell (true means use && and false means use ||).

If you want the wait to be impervious to previously launched background tasks put it in the subshell (()) like this:

% (cmd1 &; cmd2 &; cmd3 &; wait) && thing_to_do_after


% (cmd1 &; cmd2 &; cmd3 &; wait; thing_to_do_after)

//please be aware that I haven't used tcsh in ages...

share|improve this answer
This almost works perfectly! Could you modify your answer to have 1 slight tweak -- combine the two answers so the combination is impervious to other background commands launched from the same shell: ( cmd1 & ; cmd 2 & ; cmd 3 & ; wait ) && thing_to_do_after Also, your second answer blocks on cmd3, but not on cmd2 and cmd1. – Ross Rogers Jul 9 '10 at 20:45
@Ross: tweaked as requested. – dmckee Jul 10 '10 at 0:59

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.