我在Shell脚本子菜单选项程序中收到错误

时间:2015-03-08 14:56:04

标签: shell

我正在制作子菜单用户选项类型的程序,无法理解为什么它甚至无法正常工作。 我的努力代码是: -

#!/bin/sh
#
# Main Program
#
choice=10
option=10
while [$choice -ne 5]
do
    clear
    echo "------------------------------"
    echo "Main Menu"
    echo "------------------------------"
    echo "[1] FIle Utilities"
    echo "[2] Process Utilities"
    echo "[3] Alias Utilities"
    echo "[4] Envorinment Utilites"
    echo "[5] Exit"
    echo "------------------------------"
    read choice
    case $choice in
    1) clear
       while [$option -ne 4]
       do
       clear
       echo "------------------------------"
       echo "File Utilities"
       echo "------------------------------"
       echo "[1] Change File Permission"
       echo "[2] Move a File"
       echo "[3] Dump Dir"
       echo "[4] Return to Main Menu"
       echo "------------------------------"
       read option
       option=4;
       done;;
    2) clear
       option=10;
       while [$option -ne 3]
       do
       clear
       echo "------------------------------"
       echo "Process Utilities"
       echo "------------------------------"
       echo "[1] Dump Process"
       echo "[2] Kill Process"
       echo "[3] Return to Main Menu"
       echo "------------------------------"
       read option
       option=3;
       done;;
    3) clear
       option=10;
       while [$option -ne 3]
       do
       clear
       echo "------------------------------"
       echo "Alias Utilities"
       echo "------------------------------"
       echo "[1] Create Alias"
       echo "[2] Remove Alias"
       echo "[3] Return to Main Menu"
       echo "------------------------------"
       read option
       option=3;
       done;;
    4) clear
       option=10;
       while [$option -ne 3]
       do
       clear
       echo "------------------------------"
       echo "Environment Utilities"
       echo "------------------------------"
       echo "[1] Dump Environment"
       echo "[2] Modify Environment"
       echo "[3] Return to Main Menu"
       echo "------------------------------"
       read option
       option=3;
       done;;
    5) clear
       clear
       echo "------------------------------"
       echo "Program Exit"
       echo "------------------------------";;
    *) clear
       echo " Wrong Input Selected ";;
    esac
 done

我得到的错误是: - ./ main:7:。/ main:[10:未找到

请帮助我,我做错了......

1 个答案:

答案 0 :(得分:0)

这里:

while [$choice -ne 5]

[是一个程序,而不仅仅是语法。 (在提示符处,键入type [help [

与任何程序一样,shell需要在它与其参数之间留一个空格。

while [ $choice -ne 5 ]