shell 双括号((...))作用

来源:互联网 发布:b超单的数据怎么看 编辑:程序博客网 时间:2024/05/29 08:35

((...))

作用:拓展并执行算数表达式,如果表达式值为0, 则返回1或者false; 非0,则返回0或者true.

可以用的地方有两个:1.作为测试的手段,2.作为算数表达式计算的手段。

The (( )) construct expands and evaluates an arithmetic expression. If the expression evaluates as zero, it
returns an exit status of 1, or "false". A non-zero expression returns an exit status of 0, or "true". This is in
marked contrast to using the test and [ ] constructs previously discussed.

原创粉丝点击