语法
##一 语法
select表达式是bash的一种扩展应用,擅长于交互式场合。用户可以从一组不同的值中进行选择
select var in ...
do
...
break
done
# 案例
#!/bin/bash PS3='choose one: ' # select默认使用PS3变量的值做提示符
echo
select var in {A..D}
do
echo
echo "your choose is $var" echo "OK"
echo
break # 跳出select,否则是死循环
done
sh ./select.sh
1) A
2) B
3) C
4) D
choose one: 3
your choose is C
OK