Chinaunix首页 | 论坛 | 博客
  • 博客访问: 251260
  • 博文数量: 93
  • 博客积分: 3001
  • 博客等级: 中校
  • 技术积分: 1050
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-11 13:20
文章分类

全部博文(93)

文章存档

2011年(1)

2009年(92)

我的朋友

分类: LINUX

2009-07-13 09:41:49

#!/bin/bash
function test () {
  while true
  do
     echo "adding information"
     echo "your name ?"
     read name
     echo "your sex ?"
     read sex
     echo "your age ?"
     read age
     echo "$name:$sex:$age"
     read -p "is this correct?"
         case "$REPLY" in
             [yY]*)
                   echo "adding informati..........."
                   echo "$name:$sex:$age">>datafile
                   sort -u datafile -o datafile
                   echo -n "do you want to go back to the main menu?"
                   read ans
                      if [[ $ans == [nN] ]]
                      then
                          return
                      else
                      continue
                      fi
              ;;
                *)
                    echo "do you want to try again?"
                    read answer
                           case "$answer" in
                              [yY]*)
                                  continue
                                 ;;
                                 *)
                                    exit
                                 ;;
                               esac
                 ;;
           esac
done
}
datafile=$HOME/datafile
if [ -e $datafile ]
then
 echo "$(basename $datafile) does not exitst" >&2
   exit 1
fi
PS3="select one :"
select answer in 'add info' 'delete info' 'update info' exit
do
   case $answer in
       "add info")
                     test
                     break
                       ;;
       "delete info")
                       ls
                      break
                       ;;
       "update info")
                      echo "updating~~~~~~~"
                       break
                       ;;
              exit)
                      echo "bye bye"
                        exit 0
                       ;;
                *)
                     echo "bad choice"
                      continue
                       ;;
    esac
done
阅读(677) | 评论(0) | 转发(0) |
0

上一篇:监控jboos

下一篇:优化总结

给主人留下些什么吧!~~