Quantcast
Viewing latest article 1
Browse Latest Browse All 15

Create a simple menu with case for your shell script

Create a menu for you script is a good idea if you use CASE, in this example below is just put your options between the number [ ex. 1) ] and ;; 

##### begin script #####
#!/bin/bash
#menu with case
#by jmbarros@tech4it.com.br
clear
echo -e "Choice your option (1 or 2 or 3)/n?"
echo -e "	1) Create User..."
echo -e "	2) Change password..."
echo -e "	3) Validating user..."
echo -e "	4) Exit!"

read INPUT;

case $INPUT in

1)
echo "Username? (without spaces... pls!)"
read user

;;
2)
exit
;;
3)
exit
;;
4)
echo "Exiting..."
exit
;;
*)
echo "You don't choose a valid option, exiting..."
exit
,,
esac
####### end script ######

Copy and paste in your terminal or download here!

Image may be NSFW.
Clik here to view.

Viewing latest article 1
Browse Latest Browse All 15

Trending Articles