分类: LINUX
2018-03-17 10:34:09
#!/bin/bash
printf "Where are you from:\n"
select place in "Bejing" "shenzhen" "shanghai" "shaoguan" "guangzhou"
do
printf "you have select ${place}\n"
if [ ${place} = "shaoguan" ];then
printf "I'm from ${place}\n"
break
fi
done
tay@tay:/mnt/hgfs/hzs/shell$ ./select.sh
Where are you from:
1) Bejing
2) shenzhen
3) shanghai
4) shaoguan
5) guangzhou
#? 5
you have select guangzhou
#? 3
you have select shanghai
#? 4
you have select shaoguan
I'm from shaoguan
tay@tay:/mnt/hgfs/hzs/shell$
tay@tay:/mnt/hgfs/hzs/shell$ ./select.sh
Where are you from:
1) Bejing
2) shenzhen
3) shanghai
4) shaoguan
5) guangzhou
#? 5
you have select guangzhou
#? 3
you have select shanghai
#? 4
you have select shaoguan
I'm from shaoguan
tay@tay:/mnt/hgfs/hzs/shell$