Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29109

How to run group of commands in parallel followed by an other command

I want to execute cmdA, cmdB and cmdC in parallel before cmdD. This is what I have so far:

$> (cmdA & cmdB & cmdC) && cmdD

As long as cmdC finished last this works, but, for example, if cmdC finishes first, cmdD is executed right away. So, my question is, how can I wait for all three commands befofe executing cmdD? Is this possible with just && and &?

Upvotes: 1

Views: 68

Answers (1)

KamilCuk
KamilCuk

Reputation: 140930

how can I wait for all three commands befofe executing cmdD?

Use wait.

(cmdA & cmdB & cmdC ; wait) ; cmdD

Upvotes: 2

Related Questions