11lxm 发表于 2018-8-26 06:21:58

=~的用法_shell脚本

  工作环境:Red Hat Enterprise Linux Server>  #!/bin/bash
  #
  [ "$1" == "" ] && echo "语法错误"
  [[ "$1" =~ ^ ]] && echo "数字开头"
  [[ "$1" =~ ^ ]] && echo "字母开头"
  #!/bin/bash
  #
  read -p "input password:" pass
  #a="`echo $pass`"
  [[ "${#pass}" -ge 5 && "${#pass}" -le 8]] && echo "OK" || echo "NO"
  if [[ "${#pass}" -gt 8 ]];then
  end=`echo $pass | cut -c 1-8`
  echo $end
  fi
  注意:=~的意思是开启正则表达式

页: [1]
查看完整版本: =~的用法_shell脚本