shell学习之select循环
#!/bin/bash#save PS3
oPS3=$PS3
PS3="choose the way:"
function way1 (){
echo "you are using () to add"
tmp1=$((nu1 + nu2))
echo "value is $tmp1"
}
function way2(){
echo "you are using expr to add"
echo "value is `expr ${nu1} + ${nu2}`"
}
function way3(){
echo "you are using let to add"
let tmp2=${nu1}+${nu2}
echo "value is $tmp2"
}
read -p "please input two to test:" nu1 nu2
select cal in '(())' 'expr' 'let' 'q'
do
case $cal in
'(())')
way1;;
'expr')
way2;;
'let')
way3;;
'q')
exit 0;;
* )
echo "wrong argv";;
esac
done
#restore PS3
PS3=$oPS3
页:
[1]