Let’s Make A Menu With case in Linux/Bash!

This here bash code shows a pointless password change utility but it shows using case and what not.  Enjoy!

#!/bin/bash

clear
echo “PASSWORD CHANGE UTILITY”
echo “———————–“
echo ” “
echo -n “Enter a user name:”
read answer
echo -n “Are you sure? (y/n):”
read choice

case $choice in

y|Y)
sudo passwd $answer
clear
echo -n “Password successfully changed. Press enter to continue”
read success
;;
n|N)

echo -n “whatever, don’t change it”

;;
esac

# Is that cool or what?!?!

 

Mm.,