
Command to wait for previous process/command to finish
Well, that's what will happen by default when you run a set of
commands. But I'll assume that you want to be able to do something a
little bit fancier.
So:
################################################
# Execute command_1 in the background.
# Get its PID.
# Run some other commands.
# Then wait for command_1 to finish.
command_1 &
PID_1=$!
run_other_command
run_other_command
do_something_else
wait $PID_1
################################################
# Now that command_1 has finished....
# Execute command_2 in the background.
# Get its PID.
# Run some other commands.
# Then wait for command_2 to finish.
command_2 &
PID_2=$!
run_other_command
run_other_command
do_something_else
wait $PID_2
################################################
# etc...