第一个shell脚本

回复 收藏
本帖最后由 sinni029 于 2015-8-30 21:37 编辑
  1. #!/bin/bash
  2. while :
  3. do
  4. read -p "Please input a number: " n
  5. if [ $n == q ];then
  6.     exit
  7. fi
  8. m=`echo $n|sed 's/[^0-9]//g '`
  9. if [ ! -z "$m" ];then
  10.     s=$[$n%2]
  11.     case $s in
  12.         1)  
  13.            echo "The number is odd number."
  14.            ;;  
  15.         0)  
  16.            echo "The number is even number."
  17.            ;;  
  18.     esac
  19.     exit 0


这是我写的第一个shell脚本。{:4_91:}

2015-08-30 21:21 举报
已邀请:
0

wangqs

赞同来自:

666
0

杭州小白

赞同来自:

你还可以加入小数,负数出现的情况{:4_103:}

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: