ywg 发表于 2018-8-20 11:08:33

shell 的条件执行

  条件测试
  1.test命令:
  文件属性测试
  字符串测试
  算术测试
  语法: test EXPRESSION
  或
  [ EXPRESSION ]
  在bash中还有一个` `,它是[]的提高版本。
  ` EXPRESSION `
  [ 10 \> 9][[ 10 > 9]]
  2. if 的语法结构
  if test-commands; then consequent-commands; fi
  或
  if test-commands; then
  consequent-commands
  fi
  或
  if test-commands
  then
  consequent-commands
  fi
  3.if...else...fi
  if []
  then
  else
  fi
  4.if...elif...else...fi
  if [];then
  commands
  elif [];then
  commands
  else
  commands
  fi
  5.case 语句
  case EXPRESSION in
  PATTERN1)
  commands;;
  PATTERN2)
  commands;;
  esac

页: [1]
查看完整版本: shell 的条件执行