hb120973135 发表于 2018-8-22 08:58:37

shell的if判断比较

  shell中的if作用毋庸置疑每个80%的shell中都会应用到if判断,那么作为一个新手我应该咋整呢,今天听了一上午课,然后就把上午的东西总结了一下写成了一个脚本,然后来进行给大家聊一聊
  #!/bin/bash
  ##############################################################
  # File Name: bbjj.sh
  # Version: V1.0
  # Author: ls
  # Organization: http://shuai12138.blog.51cto.com/
  # Created Time : 2017-03-06 14:04:05
  # Description:
  ##############################################################
  read -p "pleace input: " -t 2 -n 1 x
  echo""
  read -p "pleace input: " -t 2 -n 1 y
  echo"">/dev/null
  if [ -n $x -a -n $y ]
  then
  if [[ "$x$y" =~ ^+$ ]]
  then
  if [ $x -gt $y ]
  then
  echo "$x>$y"
  elif [ $x -eq $y ]
  then
  echo "$x=$y"
  else
  echo "$x$y"
  elif [ $x -eq $y ]
  then
  echo "$x=$y"
  else
  echo "$x
页: [1]
查看完整版本: shell的if判断比较