test 查看两个字符串是否相等
   #!/bin/bash
   echo "please input two string:"
   read -p "string1: " first
   read -p "string2: " second
   test $first == $second  && echo "$first same $second "||echo "$first not same $second "
中括号进行判断
  #!/bin/bash
  echo "please input two string:"
  read -p "string1: " first
  read -p "string2: " second
 [ "$first" == "$second" ]  && echo "$first same $second "||echo "$first not same $second "
如果不加双引号:会显示参数太多 。不管是变量还是字符串都得加上双引号

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐