I'm trying to find a way to run multiple commands in parallel in sh
and wait for it completion.
I've found that following doesn't work (sh: 1: Syntax error: ";" unexpected
):
sh -c '(sleep 3 && echo 1) & ; (sleep 3 && echo 2) & ; wait'
But this syntax works as expected:
sh -c '(sleep 3 && echo 1) & ;; (sleep 3 && echo 2) & ;; wait'
But I don't understand what is the difference.
What is the meaning of ;;
and when it should be used?