现在的位置: 首页 > 综合 > 正文

CTDP linux 程序员手册 (4.6) 一个循环脚本的例子

2014年02月13日 ⁄ 综合 ⁄ 共 469字 ⁄ 字号 评论关闭

一个循环脚本的例子
下面这个文件阐释了前面讲到得循环和控制语句:
#! /bin/bash   
# Use the bash shell to run the script
# This is an example file to take entries from the user
# entries Version 1.0 May 22, 2000
DONE=no
ENTRIES="hello bye ls 1"
while [ $DONE = no ]
do
   echo Valid entries are: $ENTRIES
   read ENTRY             # 用户输入变量 ENTRY 的值
   case $ENTRY in
   1)
       pwd
       ;;
   hello)
       echo How are you?
       ;;
   bye)
       echo exiting...
       DONE=yes
       ;;
   ls)
       ls -al |more
       ;;
   *)
       echo $ENTRY is an unrecognized command.
       ;;
   esac
done

 

抱歉!评论已关闭.