今天在写脚本的时候,用到了判断某变量是否是字符串“hello”。
之前是
if [ $temp == "hello" ]; then
……
fi
但是后来不能用了
错误提示line 17: [: ==: unary operator expected
找了半天没发现错误,后来吧if的条件语句改为
if [ $temp=="hello" ]; then
……
fi
就好了
就是说,去掉了==符号两边的空格。
今天在写脚本的时候,用到了判断某变量是否是字符串“hello”。
之前是
if [ $temp == "hello" ]; then
……
fi
但是后来不能用了
错误提示line 17: [: ==: unary operator expected
找了半天没发现错误,后来吧if的条件语句改为
if [ $temp=="hello" ]; then
……
fi
就好了
就是说,去掉了==符号两边的空格。