[娱乐] Shell 菜单

介绍

基本信息

作者:朱明宇
名称:菜单
作用:提供一个可以供用户进行选择的菜单

使用方法

1. 给此脚本添加执行权限
2. 执行此脚本

脚本

#!/bin/bash

while true
do
        echo
        echo '====== Optional Item ======'
        echo '1.choose CentOS'
        echo '2.choose RHEL'
        echo '3.choose openSUSE'
        echo '4.choose SUSE'
        echo '*.Enter other keys to exit'
        echo
        read -p 'Which one do you want to choose ? ' choose

        case $choose in
        1)
                echo
                echo
                echo '=========  Result ========='
                echo 'You have choosed CentOS'
                echo ;;
        2)
                echo
                echo
                echo '=========  Result ========='
                echo 'You have choosed RHEL'
                echo ;;
        3)
                echo
                echo
                echo '=========  Result ========='
                echo 'You have choosed openSUSE'
                echo ;;
        4)
                echo
                echo
                echo '=========  Result ========='
                echo 'You have choosed SUSE'
                echo ;;
        *)
                exit 1 ;;
        esac
done