1.case语句控制流
#!/bin/sh
echo "please input number 1 to 3"
read number
case $number in
1) echo "you input 1"
  ;;
2|3) echo "you input 2 or 3"
  ;;
*) echo "error! the number you input isn't 1 to 3"
 ;;
esac
按顺序执行,若匹配不到前面的1,2,3,到匹配到*则输出相应信息

2. select语句控制

select var in ... ; do

break
done

$var


#!/bin/sh
echo "What is your favourite firuit?"
echo "1) Apple"
echo "2) Orange"
echo "3) Banana"
read number
case $number in
1)echo "your favourite firuit is Apple."
;;
2)echo "your favourite firuit is Orange."
;;
3)echo "your favourite firuit is Banana."
;;
esac
#!/bin/sh
echo "What is your favourite firuit?"
select var in "Apple" "Orange" "Banana";do
break
done
echo "your favourite firuit is $var."
执行以上脚本,均可实现下面交互式功能
What is your favourite firuit?
1) Apple
2) Orange
3) Banana
#? 1
your favourite firuit is Apple.