在Bash IF条件下,感叹号代表否定吗? [英] Does the Exclamation point represent negation in Bash IF condition?

查看:142
本文介绍了在Bash IF条件下,感叹号代表否定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了类似

if ! some-command; then
    #do something
fi

感叹号的作用是什么?我发现如果使用方括号,它可以用于否定.

What's the effect of the exclamation point? I see that if you use brackets, 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 IF条件下,感叹号代表否定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆