Skip to content

Instantly share code, notes, and snippets.

@andrross
Created February 17, 2023 18:10
Show Gist options
  • Save andrross/b945fef5170401f518a1c73129f6414c to your computer and use it in GitHub Desktop.
Save andrross/b945fef5170401f518a1c73129f6414c to your computer and use it in GitHub Desktop.
Bash script to repeat a command until a non-zero exit code
#!/bin/bash
i=1
while [ true ]
do
"$@"
if [ "$?" = 0 ]; then
echo "SUCCESS ($i)"
else
echo "FAILURE ($i)"
break
fi
((i=i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment