红联Linux门户
Linux帮助

shell脚本case.....esac

发布时间:2009-05-17 06:36:50来源:红联作者:2008chenwanxi
我的脚本如下,
echo "secvise"
echo "1)ls"
echo "2)ls -l"
echo "3)Exit"
echo "choice[1-3]"
read choice

case $choice is
1) ls;;
2) ls -l;;
3) exit;;
*) echo "wrong";;

esac
执行后,出现./diahufuwu.sh: line 8: syntax error near unexpected token `ia'
./diahufuwu.sh: line 8: `case $choice ia'
好像“is”出错了,不知如何改,望各位前辈指点
文章评论

共有 4 条评论

  1. yuer520 于 2011-07-07 23:27:12发表:

    努力

  2. yuer520 于 2011-07-07 23:26:53发表:

    这样都能错?

  3. 2008chenwanxi 于 2009-05-18 10:16:24发表:

    2# dingjing

    谢谢,望成为好友,时刻得以领教

  4. dingjing 于 2009-05-17 15:10:57发表:

    case $choice is
    1) ls;;
    2) ls -l;;
    3) exit;;
    *) echo "wrong";;

    esac
    不是is,是用in,改为:
    case $choice in
    1) ls;;
    2) ls -l;;
    3) exit;;
    *) echo "wrong";;

    esac