
Linux shell :两字符串比较。 输入两不同字符串,结果确显示:the two string are equal!! 郁闷。。。。
代码为:#!/bin/bashecho"plsenterstr1"readstr1echo"plsenterstr2"readstr2if["$str1"="$str2"...
代码为:
#!/bin/bash
echo "pls enter str1"
read str1
echo "pls enter str2"
read str2
if [ "$str1"="$str2" ];then
echo "the two string are equal!!"
else
echo "the two tring are different!!"
fi
read str2
对了,后面的read str2 多余的 展开
#!/bin/bash
echo "pls enter str1"
read str1
echo "pls enter str2"
read str2
if [ "$str1"="$str2" ];then
echo "the two string are equal!!"
else
echo "the two tring are different!!"
fi
read str2
对了,后面的read str2 多余的 展开
2个回答
展开全部
一看就知道你没掌握好基础
你的if语法都不对
这里告诉你正确的语法,
if [ $str1 = $str2 ] ; then
...
else
...
fi
你的if语法都不对
这里告诉你正确的语法,
if [ $str1 = $str2 ] ; then
...
else
...
fi
追问
不是跟你一样呀,没错呀,我想知道具体哪里出了问题。。。。3q
追答
仔细看 注意空格
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询