How do you run multiple programs in parallel from a bash script?
How about:
prog1 & prog2 && fg
This will:
- Start
prog1
. - Send it to background, but keep printing its output.
- Start
prog2
, and keep it in foreground, so you can close it withctrl-c
. - When you close
prog2
, you'll return toprog1
's foreground, so you can also close it withctrl-c
.
To run multiple programs in parallel:
prog1 &
prog2 &
If you need your script to wait for the programs to finish, you can add:
wait
at the point where you want the script to wait for them.