+ -
当前位置:首页 → 问答吧 → shell脚本case.....esac

shell脚本case.....esac

时间:2009-05-17

来源:互联网

我的脚本如下,
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”出错了,不知如何改,望各位前辈指点

作者: 2008chenwanxi   发布时间: 2009-05-17

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

作者: dingjing   发布时间: 2009-05-17

dingjing

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

作者: 2008chenwanxi   发布时间: 2009-05-18

这样都能错?

作者: yuer520   发布时间: 2011-07-07

努力

作者: yuer520   发布时间: 2011-07-07