Chinaunix首页 | 论坛 | 博客
  • 博客访问: 906010
  • 博文数量: 75
  • 博客积分: 1216
  • 博客等级: 少尉
  • 技术积分: 1998
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-11 16:20
个人简介

优秀是一种习惯

文章分类

全部博文(75)

文章存档

2014年(1)

2013年(29)

2012年(45)

分类: Python/Ruby

2012-10-08 13:17:00

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