<分区>
我不确定如何在 shell 中使用多个测试来执行 if
。我在编写此脚本时遇到问题:
echo "You have provided the following arguments $arg1 $arg2 $arg3"
if [ "$arg1" = "$arg2" && "$arg1" != "$arg3" ]
then
echo "Two of the provided args are equal."
exit 3
elif [ $arg1 = $arg2 && $arg1 = $arg3 ]
then
echo "All of the specified args are equal"
exit 0
else
echo "All of the specified args are different"
exit 4
fi
问题是我每次都会收到这个错误:
./compare.sh: [: missing `]' command not found