Last active
February 16, 2024 10:55
-
-
Save pkutaj/641ca02980fca3cef28e7e123461c6fb to your computer and use it in GitHub Desktop.
Ask for Input in Bash
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
echo -n "Are you sure (Y/N)? " #01 | |
answered= #02 | |
while [[ ! $answered ]]; do #03 | |
read -r -n 1 -s answer #04 | |
if [[ $answer = [Yy] ]]; then #05 | |
answered="yes" #06 | |
elif [[ $answer = [Nn] ]]; then #07 | |
answered="no" #08 | |
fi #09 | |
done #10 | |
printf "\n%s\n" $answered #12 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment