BASH – Run command until success

How to run a command repeatedly until it succeeds:

while [ $? -ne 0 ]; do !!; done

The !! is a shortcut to the last command run. Run the command once and then the while loop will execute until the command succeeds (i.e. returns 0)

From here:

Leave a Reply

Your email address will not be published. Required fields are marked *