我的脚本的这一部分检查发行版是 Ubuntu 还是 Arch。问题是我无法弄清楚用什么替换 OR 以使其工作。我尝试了 -o
和来自各个网站的其他建议,但均未成功。
if [ ! $(lsb_release -is) == "Ubuntu" OR "Arch" ]; then
echo "Neither Ubuntu nor Arch!"
read -p "Continue anyway(y/N)? "
sleep 0
[ "$REPLY" == "y" ] || exit
fi
最佳答案
你可以使用类似的东西:
rel="$(lsb_release -is)"
if [[ "${rel}" != "Ubuntu" && "${rel}" != "Arch" ]]; then
# Neither Ubuntu nor Arch
fi
关于bash - 如何在(负)Bash 条件下使用 OR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7376058/