#!/bin/bash
echo "Please chose a number"
select number in w top free quit
do
case $number in
w)
w
;;
top)
top
;;
free)
free
;;
quit)
exit
;;
*)
echo "Please input number 1-4"
esac
echo "Please chose a number"
select number in w top free quit
do
case $number in
w)
w
;;
top)
top
;;
free)
free
;;
quit)
exit
;;
*)
echo "Please input number 1-4"
esac
主要用到select do done语句,select本身就是循环语句
使用
select number in ... ;
do break; done
case 用于需要进行多重分支,主要进行判断,选择项) 执行;; *) 结尾 esac结束