Created
February 11, 2023 14:30
-
-
Save DevGW/a00ceedec3881e336123909eb98387d4 to your computer and use it in GitHub Desktop.
#bash wait do while waiting for jobs to end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
echo "starting" | |
sleep 2 & | |
sleep 4 & | |
sleep 6 & | |
sleep 8 & | |
while true; do | |
JOBS=`jobs -p | wc -l` | |
# workaround about jobs bug. If don't execute it explicitily, | |
# JOBS will stick at 1, even when no jobs are running anymore. | |
jobs &>/dev/null | |
if [ $JOBS -ne 0 ]; then | |
printf "." | |
else | |
printf "\n" | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment