不等于 shell 中的条件或条件

问题描述 投票:0回答:0

获得了具有如下条件评估的脚本,但即使在传递了正确的参数后也没有产生预期的结果。

bash-4.2$ cat foo.ksh
#!/bin/ksh

to_clean=$1

if [ "${to_clean}" != "dryrun" ] || [ "${to_clean}" != "remove" ]; then
   echo "Not valid option. Specify either of dryrun OR remove" && exit 2
fi

这是运行结果

bash-4.2$ ./foo.ksh dryrun
Not valid option. Specify either of dryrun OR remove

是否需要使用

ne
或像
[[
这样的测试运算符来完成字符串比较?

shell unix ksh
© www.soinside.com 2019 - 2024. All rights reserved.