Skip to content

Instantly share code, notes, and snippets.

@IkarosKappler
Created December 18, 2019 23:13
Show Gist options
  • Save IkarosKappler/8254f2cc01fe73f975ace8cd99d29ef6 to your computer and use it in GitHub Desktop.
Save IkarosKappler/8254f2cc01fe73f975ace8cd99d29ef6 to your computer and use it in GitHub Desktop.
A bash snippet to request a Y/N confirmation from the user.
#!/bin/bash
while true; do
read -p "Do you really wish to do this thing? (y/n)? " yn
case $yn in
[Yy]* ) echo "Doing the thing now."; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment