bash - 感叹号是否代表 Bash IF 条件中的否定?

标签 bash if-statement conditional-statements

我看到了类似的东西

if ! some-command; then
    #do something
fi

感叹号有什么作用?我看到如果你使用括号,it can be used for negation .

这里的效果一样吗?

最佳答案

man bash 中所述:

If the reserved word ! precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above.

关于bash - 感叹号是否代表 Bash IF 条件中的否定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41495350/

相关文章:

python - 在 Python 中重构长语句

linux - Vim:将所有注释移至文件顶部

python - 从python获取java版本号

javascript - 关于JS嵌套if语句的更好解决方案

javascript - 我该如何做类似 "if (a > x > b)"的事情?

python - 给定奇数或偶数条件,如何对列表中的偶数或奇数求和?

linux - 有没有办法在手册页中查找标志?

bash - 单个文件的特殊 Emacs 设置 : Run lisp code at startup from command line

java - 当未输入任何内容并按下按钮时 Android 应用程序崩溃

c# - 条件委托(delegate)?