Skip to content

Instantly share code, notes, and snippets.

@Rumbles
Last active August 29, 2015 14:26
Show Gist options
  • Save Rumbles/13ae1a6d6848c4493511 to your computer and use it in GitHub Desktop.
Save Rumbles/13ae1a6d6848c4493511 to your computer and use it in GitHub Desktop.
While loop that prompts for input until an integer is entered
#This part works, it prompts the user for input, and doesn't stop prompting until there is a valid string
while [ -z "$description" ]; do
echo -n "Please enter a description for use in the config file: "
read description
done
#This part doesn't work, it continues to prompt whether there is a valid integer or not
while ! [[ $listID =~ '^[0-9]+$' ]]; do
echo -n "Please enter the list ID: "
read $listID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment