Linux的判断两个字符串是否相等
test 查看两个字符串是否相等#!/bin/bashecho "please input two string:"read -p "string1: " firstread -p "string2: " secondtest $first == $second&& echo "$first same $second "||echo "$first not same $second
·
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 "
如果不加双引号:会显示参数太多 。不管是变量还是字符串都得加上双引号
更多推荐
所有评论(0)