ty9919 发表于 2018-8-19 11:27:53

shell-5:case比if(elif else)方便

  # cat case.sh
  #!/bin/bash
  read -p "tap a num to echo:" num
  case $num in
  1)
  echo 1 ;;
  2)
  echo 2 ;;
  3)
  echo 3 ;;
  *)
  echo "other num" ;;
  esac
  # sh case.sh
  tap a num to echo:1
  1
  # sh case.sh
  tap a num to echo:4
  other num
  #

页: [1]
查看完整版本: shell-5:case比if(elif else)方便