获得了具有如下条件评估的脚本,但即使在传递了正确的参数后也没有产生预期的结果。
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
或像 [[
这样的测试运算符来完成字符串比较?