Is it possible for bash commands to continue before the result of the previous command?

Yes, if you do nothing else then commands in a bash script are serialized. You can tell bash to run a bunch of commands in parallel, and then wait for them all to finish, but doing something like this:

command1 &
command2 &
command3 &
wait

The ampersands at the end of each of the first three lines tells bash to run the command in the background. The fourth command, wait, tells bash to wait until all the child processes have exited.

Note that if you do things this way, you’ll be unable to get the exit status of the child commands (and set -e won’t work), so you won’t be able to tell whether they succeeded or failed in the usual way.

The bash manual has more information (search for wait, about two-thirds of the way down).

Leave a Comment