Ying Xiong
Ying Xiong

Reputation: 4928

Run shell command in parallel and wait for result

I want to run command_a and command_b in parallel, and wait for both of them finishing to start another command_c. Is there a simple command/idiom in shell that allows me do that?

Upvotes: 2

Views: 1017

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272217

Can you simply do

$ command_a &
$ command_b &
$ wait

(the ampersand puts the shell job in the background)

From https://ss64.com/bash/wait.html

If n is not given, all currently active child processes are waited for, and the return status is zero.

Upvotes: 5

Related Questions