wait
verb
say it: “WAYT” /weɪt/
A shell command that pauses a script until the background jobs it started have finished.
What does wait do in bash?
wait pauses a script until the background jobs it started with & have finished. Start a dozen jobs side by side, then wait, and the next line runs only when the last one is done. wait followed by a process ID waits for that one job alone.
for p in photos/*.jpg; do
./resize.sh "$p" &
done
wait
echo "All done."
In a sentence
- “Without wait, 'All done.' printed before the photos were finished.”
- “The script started twelve resizes with & and then called wait.”
Level: Journeyman · More Unix terms at this level
Updated