shell中的if比较

virusswb virusswb 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
autoTaskFinish.sh查询数据库,有返回值
if [ "$rtn" -ge 1 ]; then
echo "0"
exit 0
else
echo "1"
exit 100
fi

下面的这个shell调用上面的shell
#!/bin/bash
vday=$1


while true;
do
vexists=`sh /home/oracle/shell/new/autoTaskFinish.sh $1`
echo $vexists
if [ $vexists -eq 0 ]; then
echo "autotask is finished."
fi
# if [[ "$vexists" -eq 0 ]]; then
# echo "autotask is finished."
# break
# else
# echo "autotask is not finished. continue....."
# echo "sleep 5s"
# sleep 2s
# fi
done


运行的时候报错了,[: too many arguments
我修改为
if [[ $vexists -eq 0 ]]
还是报错syntax error in expression (error token is ":

改成
if [[ "$vexists" -eq 0 ]]
还是报错syntax error in expression (error token is ":

我修改为if [[ "$vexists" == "0" ]]; then
不会报错了,但是始终是不会进入这个if条件,不管之前的shell返回的是0还是1,也就是判断失效了,哪位帮忙解释一下!!!
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
virusswb
Linux/Unix社区 23,224 成员 74,535 内容