当我运行bash脚本,通过它运行时,它吐出了这个错误[: !=: unary operator expected
。if语句提到一个字错误有 - [:!=:一元运算符预期
在这个函数中:
function undeploy {
echo Removing ${SITE} from ${i} ....
rm -rf /net/${i}/${JBPATH}/${FILEOLD}
if [ $? -ne 0 ] ; then
echo "Nothing to remove, proceeding to copy new WAR"
else
echo "WAR removed, waiting for Undeploy...."
tail -1f /net/${i}/var/log/jboss/server.log | while read LINE ; do if [[ "${LINE}" =~ "Undeployed" ]] ; then if [[ ${LINE} =~ "${SITE}" ]] ; then break ; fi ; fi ; done
check
fi
if [ $4 != force ]; then
echo "Un-deployment completed ${i}. Continue?"
read Continue
case "${Continue}" in
Y|y|yes|YES|Yes) echo "Continuing"
;;
*) echo "Exiting"
exit 1
;;
esac
fi
}
线if [ $4 != force ];
然后导致错误。
有谁知道为什么?我曾尝试在单引号和双引号中加入部队和4美元。仍然没有运气。
什么任何想法出了毛病这里的语法?
如果您需要更多信息,请询问。
'如果[ “$ 4”!=力]' – Erik