linux shell中的如下比较字符串为什么比较不出来?
if["X$line"="X[$blockname]"];thenbegin_block=1#echo"3"continuefi如下是我打出来的X$line和X[$blo...
if [ "X$line" = "X[$blockname]" ];then
begin_block=1
#echo "3"
continue
fi
如下是我打出来的X$line和X[$blockname]的值
X[GroupM] X[GroupS]
X#ha group0 infor: 0:enable 1:disable X[GroupS]
Xha-enable=1 X[GroupS]
X#keepalive-interval,value must be in <500-60000> X[GroupS]
Xkeepalive-interval=1000 X[GroupS]
X# retry-times,value must be in <1-10> X[GroupS]
Xretry-times=3 X[GroupS]
X# device-priority,value must be in <1-255> X[GroupS]
Xdevice-priority=128 X[GroupS]
X#haifname,value must be ha or ethernet name X[GroupS]
Xhaifname=ha X[GroupS]
X#prempt, value must be in <0-1> X[GroupS]
Xprempt=0 X[GroupS]
X# configuration-synchronization ,value must be in <0-1> X[GroupS]
Xconfiguration-synchronization=0 X[GroupS]
X# user-synchronization ,value must be in <0-1> X[GroupS]
Xuser-synchronization=0 X[GroupS]
X[GroupS] X[GroupS]----这一行是完全一样的,为什么始终进不了if条件分支?
X#ha group0 infor: 0:enable 1:disable X[GroupS]
Xha-enable=0 X[GroupS]
Xkeepalive-interval=1000 X[GroupS]
Xretry-times=3 X[GroupS]
Xdevice-priority=128 X[GroupS]
Xhaifname=ha X[GroupS]
Xprempt=0 X[GroupS]
Xconfiguration-synchronization=0 X[GroupS]
Xuser-synchronization=0 X[GroupS] 展开
begin_block=1
#echo "3"
continue
fi
如下是我打出来的X$line和X[$blockname]的值
X[GroupM] X[GroupS]
X#ha group0 infor: 0:enable 1:disable X[GroupS]
Xha-enable=1 X[GroupS]
X#keepalive-interval,value must be in <500-60000> X[GroupS]
Xkeepalive-interval=1000 X[GroupS]
X# retry-times,value must be in <1-10> X[GroupS]
Xretry-times=3 X[GroupS]
X# device-priority,value must be in <1-255> X[GroupS]
Xdevice-priority=128 X[GroupS]
X#haifname,value must be ha or ethernet name X[GroupS]
Xhaifname=ha X[GroupS]
X#prempt, value must be in <0-1> X[GroupS]
Xprempt=0 X[GroupS]
X# configuration-synchronization ,value must be in <0-1> X[GroupS]
Xconfiguration-synchronization=0 X[GroupS]
X# user-synchronization ,value must be in <0-1> X[GroupS]
Xuser-synchronization=0 X[GroupS]
X[GroupS] X[GroupS]----这一行是完全一样的,为什么始终进不了if条件分支?
X#ha group0 infor: 0:enable 1:disable X[GroupS]
Xha-enable=0 X[GroupS]
Xkeepalive-interval=1000 X[GroupS]
Xretry-times=3 X[GroupS]
Xdevice-priority=128 X[GroupS]
Xhaifname=ha X[GroupS]
Xprempt=0 X[GroupS]
Xconfiguration-synchronization=0 X[GroupS]
Xuser-synchronization=0 X[GroupS] 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询