Bash natively supports a
wait will wait for all child processes to complete before continuing an execution. For most cases, this is sufficient.
& character at the ending of a line sends the process to the background to complete. Without
wait, the the script would end.
The script will complete in 2 seconds.
Output variation 1:
Output variation 2:
wait allows for a process id argument value. This may be useful for establishing chained
In the example below, the “hi3” task depends on “hi”; however “hi2” may run in parallel with “hi”.
The process id of the last execution is returned using