Chinaunix首页 | 论坛 | 博客
  • 博客访问: 261216
  • 博文数量: 39
  • 博客积分: 1126
  • 博客等级: 准尉
  • 技术积分: 502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-28 11:34
文章分类

全部博文(39)

文章存档

2012年(7)

2011年(20)

2010年(12)

分类: LINUX

2012-09-17 13:27:20

select 表达式是一种bash的扩展应用,动作包括:
(1)、自动用1,2,3,4列出菜单 (没有echo指令,自动显示菜单
(2)、自动read输入选择 (没有 read指令,自动输入
(3)、赋值给变量 (没有赋值指令,自动输入数字后,赋值字符串给变量

while
echo "display current netconfig:"
do
select vi in "ifconfig -a" "hosts" "netmasks" "quit"
    do
    case $vi in
         "ifconfig -a") /sbin/ifconfig -a;;
         "hosts") more hosts;;
         "netmasks") more netmasks;;
         "quit") exit 0;;
         *) continue;;
        esac
        break
    done
done

执行效果

#sh test
display current netconfig
 1) ifconfig -a
 3) netmasks
 2) hosts
 4) quit
阅读(4956) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~