[:二元条件运算符的参数太多了

时间:2014-08-29 08:00:11

标签: bash shell scripting operators

我正在尝试编写脚本但是它给出了上述错误

 if [ [ [ "$1" != "abc" ] && [ "$1" != "def" ] ] || [ [ "$2" != "1" ] && [ "$2" != "0" ] ] ];
 then
    echo "Hello World"
 fi

1 个答案:

答案 0 :(得分:2)

小心&&||。你可以在BASH中简化它:

if [[ "$1" != "abc" && "$1" != "def" ]] || [[ "$2" != "1" && "$2" != "0" ]];
then
    echo "Hello World"
fi