Shell case 多选择语句用法举例:
case $1 in start) sh $ZK_PATH/bin/zkServer.sh start;; stop) sh $ZK_PATH/bin/zkServer.sh stop;; status) sh $ZK_PATH/bin/zkServer.sh status;; restart) sh $ZK_PATH/bin/zkServer.sh restart;; *) echo "require start|stop|status|restart" ;; esac
结合read举例:
echo "Please enter:" read param case $param in start) echo "start";; stop) echo "stop";; *) echo "require start|stop|status|restart";; esac