dryu999 发表于 2018-8-23 11:06:57

shell---if语句

vim if.sh  #!/bin/bash   //指定运行脚本的shell   //脚本开始
  #File: if.sh
  echo 'Hello, how old are you?'
  echo 'Please input your age:'
  read age               //读入数据
  if [ $age -eq 28 ]; then
  echo "You're at the age of marriage!"
  elif [ $age -gt 28 -a $age -lt 35 ]; then   //判断年龄在28到35之间
  echo "You must go on a blind date now."
  elif [ $age -lt 28 ]; then
  echo "You're still young and good to learn!"
  else
  echo "Sorry, I don't kown your age!"
  fi                                    //脚本结束
  chmod +x if.sh   //赋予执行权限
  ./if.sh   //脚本当前路径下执行脚本

页: [1]
查看完整版本: shell---if语句