Today I have learned some tricks about menu option in command line. One of these was
cat << EOF
Some lines
EOF
read -n1 -s
case $newvar in
"1") echo "";
ecsa
It's really magical. I can't find any description in man page about this option. How the input to read command was pushed into case option ? It usually use a variable to do this thing as I know.
I just want to understand the process of this combination further.
while :
do
clear
cat<<EOF
==============================
Menu Install DHCP Tool
------------------------------
Please enter your choice:
(1) Config Network Interface
(2) Check status
(3) Config DHCP server
(Q)uit
------------------------------
EOF
read -n1 -s
case "$REPLY" in
"1") config_network ;;
"2") check_status ;;
"3") config_dhcp ;;
"q") exit ;;
* ) echo "invalid option" ;;
esac
sleep 0.2
done
bash
has an inbuilt menu system for doing what you have described, and allows you to use less code, which means its more readable. you can find documentation on it hereman bash | less '+/^\s*select'