Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307536
  • 博文数量: 214
  • 博客积分: 4258
  • 博客等级: 上校
  • 技术积分: 2021
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-02 09:16
个人简介

http://blog.csdn.net/ly21st http://ly21st.blog.chinaunix.net

文章分类

全部博文(214)

文章存档

2018年(16)

2015年(1)

2014年(2)

2012年(22)

2011年(173)

分类: Python/Ruby

2011-10-13 21:24:02

#!/bin/bash
# Scriptname: tellme
# Using the old-style test command
echo -n "How old are you? "
read age
if [ $age -lt 0 -o $age -gt 120 ]
then
 echo  "Welcome to our planet! "
 exit 1  
fi
if  [ $age -ge 0 -a $age -le 12 ] 
then
 echo "A child is a garden of verses"
elif [ $age -ge 12 -a $age -le 19 ]
then
 echo "Rebel without a cause"
elif [ $age -ge 20 -a  $age -le 29 ]
then  
 echo "You got the world by the tail!!"
elif [ $age -ge  30 -a  $age -le 39 ]
then
 echo "Thirty something..."
else
 echo "Sorry I asked"
fi

 

**********************************************

#!/bin/bash
# Using the new (( )) compound let command
# Scriptname: tellme2

echo -n "How old are you? "
read age
if (( age < 0 || age > 120 ))
then
 echo "Welcome to our planet! "
 exit 1 
fi
if ((age >= 0 && age <= 12))
then                
 echo "A child is a garden of verses"
elif ((age >= 13 && age <= 19 ))   
then
   echo "Rebel without a cause"
elif (( age >= 19 &&  age <=  29 ))
then  
 echo "You got the world by the tail!!"
elif  (( age >=  30 &&  age <= 39 ))
then
 echo "Thirty something..."
else
 echo "Sorry I asked"
fi


阅读(248) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~