Recall & Review
beginner
What does the
wait command do in bash scripting?The
wait command pauses the script until all background processes started by the script finish running.Click to reveal answer
beginner
How do you start a process in the background in bash?
Add an ampersand
& at the end of the command to run it in the background, e.g., sleep 5 &.Click to reveal answer
intermediate
Can
wait be used to wait for a specific background process?Yes, by passing the process ID (PID) to
wait, you can wait for that specific process to finish.Click to reveal answer
beginner
What happens if you use
wait without any arguments?The script waits for all background processes started in the current shell to finish before continuing.
Click to reveal answer
beginner
Why is it useful to wait for background processes in a script?
Waiting ensures that all tasks finish before the script moves on or exits, preventing incomplete work or errors.
Click to reveal answer
Which symbol runs a command in the background in bash?
✗ Incorrect
The ampersand (&) runs a command in the background.
What does the
wait command do when called without arguments?✗ Incorrect
Without arguments,
wait pauses until all background processes finish.How can you wait for a specific background process in bash?
✗ Incorrect
Passing the process ID to
wait waits for that specific process.What happens if you don’t use
wait after starting background processes?✗ Incorrect
Without
wait, the script does not pause and continues running.Which command runs
sleep 10 in the background?✗ Incorrect
Adding & after the command runs it in the background.
Explain how to run multiple commands in the background and wait for all of them to finish in a bash script.
Think about how & and wait work together.
You got /3 concepts.
Describe how to wait for a specific background process using its process ID in bash.
Wait can take a number as argument.
You got /3 concepts.