【shell】case语句

时间:2024-04-20 23:05:16

case只能判断一种条件关系,而if能判断多种条件关系

【shell】case语句

#!/bin/bash
read -p "please input your choice (high/middle/low):" -t 30 choice
case $choice in
"high")
echo "your choice is $choice"
;; ##千万别漏下
"middle")
echo "your choice is $choice"
;;
"low")
echo "your choice is $choice"
;;
*)
echo "error high/middle/low"
;;
esac ##千万别漏下