F
F
fokin_nikolay19892016-08-24 17:37:04
bash
fokin_nikolay1989, 2016-08-24 17:37:04

How to make case work with a value greater than 1?

Guys, tell me how to make case on bash work more than 1 so that you can write 12 and point 12 is completed, just now you start writing and it immediately selects a value from 0-9 and that's it

function menu {
clear
echo
echo -e "\t\t\tМеню скрипта\n"
echo -e "\t1. Пинговать ya.ru"
echo -e "\t2. Информация об интерфейсах"
echo -e "\t3. Информация о памяти"
echo -e "\t0. Выход"
echo -en "\t\tВведите номер раздела: "
read -n 1 option
}
#Используем цикл While и команду Case для создания меню.
while [ $? -ne 1 ]
do
        menu
        case $option in
0)
        break ;;
1)
        ping_ya ;;
2)
        ifconfig ;;
3)
        meminfo ;;
*)
        clear
echo "Нужно выбрать раздел";;
esac
echo -en "\n\n\t\t\tНажмите любую клавишу для продолжения"
read -n 1 line
done
clear

here is an example of what i am doing

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Orlov, 2016-08-24
@fokin_nikolay1989

case "$1" in 
    start)   startme ;;
    stop)    stopme ;;
    restart) stopme; startme ;;
    *) echo "usage: $0 start|stop|restart" >&2
       exit 1
       ;;
esac

if you have a problem exactly counting two characters, then pay attention to the -n parameter for read

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question