shell脚本报错:"[: =: unary operator expected"

 shell脚本报错:"[: =: unary operator expected" 

md5_109a="81ab961153b62d207f0f517048881b5d"
 md5_109b=`md5sum install.bin|awk '{print $1}'`
 if [ $md5_109a != $md5_109b ]

原因,当文件install.bin不存在时, $md5_109b为空这样对比字符串就变成了

 if [ 81ab961153b62d207f0f517048881b5d !=  ] 显然语句就不合法了

可以改成

 if [[ $md5_109a != $md5_109b ]]

或者 if [ “$md5_109a ”a !=  “$md5_109b”a ]

问题解决

你可能感兴趣的:(expected,operator,unary)