Skip to content

Instantly share code, notes, and snippets.

@pkutaj
Last active February 16, 2024 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkutaj/641ca02980fca3cef28e7e123461c6fb to your computer and use it in GitHub Desktop.
Save pkutaj/641ca02980fca3cef28e7e123461c6fb to your computer and use it in GitHub Desktop.
Ask for Input in Bash
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