Last active
June 26, 2020 14:40
-
-
Save trongnghia203/ea4a323e07a0bfd067317b56520ee77f to your computer and use it in GitHub Desktop.
Bash: Yes/No Confirm script
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
#!/bin/bash | |
# Author: Nghia Le <trongnghia203@gmail.com> | |
# Description: | |
# - To ask user if they're sure and wanted to run this bash script as current log-in user | |
echo -e "\n" | |
read -n 1 -p "Do you want to run this bash script as $(whoami)? Yes/[No]: " YES_NO | |
echo -e "\n" | |
if [ -z ${YES_NO} ] || [ ${YES_NO} = "No" ] || [ ${YES_NO} = "no" ] || [ ${YES_NO} = "N" ] || [ ${YES_NO} = "n" ]; then | |
echo -e "\nYou select No, then it is going to exit now... " | |
sleep 1 | |
echo -e "\nGood bye now..!!!\n" | |
sleep 1 | |
exit 1 | |
elif [ ${YES_NO} = "Yes" ] || [ ${YES_NO} = "yes" ] || [ ${YES_NO} = "Y" ] || [ ${YES_NO} = "y" ]; then | |
echo -e "\nHmmmm, hummm..." | |
sleep 2 | |
echo -e "\nOkey, then it is going to run the bash script now... after 5 seconds" | |
sleep 3 | |
echo -e "\n2 seconds now..." | |
sleep 2 | |
echo -e "\nDeploying...\n" | |
else | |
echo -e "\nWrong input!!!" | |
sleep 1 | |
echo -e "\nGood bye now..!!!\n" | |
sleep 1 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment