如果 shell 脚本中的条件失败
If condition in shell script fails
我想知道这个脚本中的问题是什么,为什么这个 if 条件会通过
我看到 HI 被打印出来了,但是 type = A this if condition should not pass
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$ type="A"
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$ if [[ $type -eq "C" || $type -eq "D" ]]; then echo
"HI" ; fi
HI
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$
试试这个:
if [[ $type == "C" || $type == "D" ]]; then echo "HI" ; fi
我想知道这个脚本中的问题是什么,为什么这个 if 条件会通过 我看到 HI 被打印出来了,但是 type = A this if condition should not pass
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$ type="A"
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$ if [[ $type -eq "C" || $type -eq "D" ]]; then echo
"HI" ; fi
HI
[omega@ctsedgenode 1.1.11-SNAPSHOT_V12]$
试试这个:
if [[ $type == "C" || $type == "D" ]]; then echo "HI" ; fi