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

((...))

作用:拓展并执行算数表达式,如果表达式值为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.

你可能感兴趣的:(shell 双括号((...))作用)