bash - 如何在(负)Bash 条件下使用 OR

标签 bash if-statement user-input

我的脚本的这一部分检查发行版是 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/

相关文章:

c - 如何仅使用 fork() 和 if 连续打印多个内容?

javascript - For循环是否在预期> 1时返回1 for count

python - 空用户输入的默认值

linux - 将文本文件分割成 block 并保存

linux - 在 NodeJS 进程中创建 bash 包装器

mysql - 如果在 MySQL 的 SQL 脚本中有条件

Python Mechanize 错误 +

C 程序 - 文件 io 用户输入

bash - 成功启动systemd后执行bash脚本?

python - OSX Anaconda 默认 python