let: let 参数 [参数 ...]
    Evaluate arithmetic expressions.

    Evaluate each ARG as an arithmetic expression.  Evaluation is done in
    fixed-width integers with no check for overflow, though division by 0
    is trapped and flagged as an error.  The following list of operators is
    grouped into levels of equal-precedence operators.  The levels are listed
    in order of decreasing precedence.

        id++, id--    variable post-increment, post-decrement
        ++id, --id    variable pre-increment, pre-decrement
        -, +        unary minus, plus
        !, ~        logical and bitwise negation
        **        exponentiation
        *, /, %        multiplication, division, remainder
        +, -        addition, subtraction
        <<, >>        left and right bitwise shifts
        <=, >=, <, >    comparison
        ==, !=        equality, inequality
        &        bitwise AND
        ^        bitwise XOR
        |        bitwise OR
        &&        logical AND
        ||        logical OR
        expr ? expr : expr
                conditional operator
        =, *=, /=, %=,
        +=, -=, <<=, >>=,
        &=, ^=, |=    assignment

    Shell variables are allowed as operands.  The name of the variable
    is replaced by its value (coerced to a fixed-width integer) within
    an expression.  The variable need not have its integer attribute
    turned on to be used in an expression.

    Operators are evaluated in order of precedence.  Sub-expressions in
    parentheses are evaluated first and may override the precedence
    rules above.

    Exit Status:
    If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise.

let命令是bash中用于计算的工具,提供常用运算符还提供了方幂**运算符。在变量的房屋计算中不需要加上$来表示变量,如果表达式的值是非0,那么返回的状态值是0;否则,返回的状态值是1。

logical 逻辑的

bitwise 按位的

exponentiation 取幂的

~ bitwise negation 取补码

left and right bitwise shifts 按位左移和按位右移

比较大小(>=,<=,>,<,==,!=)(估计也就用在三目运算符这种地方了)

=为赋值

支持三元运算符

results matching ""

    No results matching ""