Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1804708
  • 博文数量: 286
  • 博客积分: 3713
  • 博客等级: 少校
  • 技术积分: 2275
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-11 09:47
个人简介

http://blog.chinaunix.net/uid/16979052.html

文章分类

全部博文(286)

文章存档

2018年(1)

2017年(16)

2016年(9)

2015年(17)

2014年(15)

2013年(112)

2012年(116)

分类:

2012-12-04 14:36:55

这个脚本可以提供给用户一系列的选项去选择。这里面的定义的finished选项挺好。

#!/bin/bash
directorylist="Finished $(ls /)"
PS3='Directory to process? ' # Set a useful select prompt
until [ "$directory" == "Finished" ]; do
    printf "%b" "\a\n\nSelect a directory to process:\n" >&2
    select directory in $directorylist; do
        # User types a number which is stored in $REPLY, but select
        # returns the value of the entry
        if [ "$directory" = "Finished" ]; then
            echo "Finished processing directories."
            break
        elif [ -d "/$directory" ]; then
            echo "You chose number $REPLY, processing $directory ..."
            # Do something here
            break
        else
            echo "Invalid selection!"
        fi # end of handle user's selection
    done # end of select a directory
done # end of while not
阅读(869) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~