Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14740
  • 博文数量: 6
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 25
  • 用 户 组: 普通用户
  • 注册时间: 2013-03-14 16:03
文章分类
文章存档

2014年(1)

2013年(5)

我的朋友

分类: Python/Ruby

2013-04-07 16:32:34

这个脚本可以提供给用户一系列的选项去选择。这里面的定义的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
阅读(613) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~