Chinaunix首页 | 论坛 | 博客
  • 博客访问: 398974
  • 博文数量: 75
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 645
  • 用 户 组: 普通用户
  • 注册时间: 2015-06-03 18:24
文章分类

全部博文(75)

文章存档

2019年(1)

2018年(20)

2017年(14)

2016年(10)

2015年(30)

分类: 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$

 

 

阅读(1139) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~