标签:blog io ar 使用 java div on 2014 log
select $var in ${list[@]} do statements that can use $var done在select执行时,会根据list数组给出选择菜单,用户选择后的结果保存在$var变量中,然后执行statements语句。执行完成后,再次给出菜单,等待用户选择。如果用户想跳出选择循环,需要在循环体中根据条件增加break语句。
#!/bin/bash fruits=( "apple" "pear" "orange" "watermelon" ) echo "Please guess which fruit I like :" select var in ${fruits[@]} do if [ $var = "apple" ]; then echo "Congratulations, you are my good firend!" break else echo "Try again!" fi done
标签:blog io ar 使用 java div on 2014 log
原文地址:http://blog.csdn.net/wzy_1988/article/details/40589941