00. 目录
01. 命令概述
let命令是bash中用于计算的工具,用于执行一个或多个表达式,变量计算中不需要加上 $ 来表示变量。如果表达式中包含了空格或其他特殊字符,则必须引起来。
02. 命令格式
用法:let 参数 [参数 ...]
03. 常用选项
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
04. 参考示例
4.1 加法运算
[root@localhost ~]# let a=3+4
[root@localhost ~]# echo $a
7
[root@localhost ~]#
4.2 自加运算
[root@localhost ~]# echo $a
7
[root@localhost ~]# let a++
[root@localhost ~]# echo $a
8
[root@localhost ~]#
4.3 自减运算
[root@localhost ~]# echo $a
8
[root@localhost ~]# let a--
[root@localhost ~]# echo $a
7
[root@localhost ~]
4.4 幂运算
[root@localhost ~]# echo $a
7
[root@localhost ~]# let a=a**a
[root@localhost ~]# echo $a
823543
[root@localhost ~]#
4.5 逻辑运算
[root@localhost ~]# let a=1||1
[root@localhost ~]# echo $a
1
[root@localhost ~]#
05. 附录
转载:https://blog.csdn.net/dengjin20104042056/article/details/100903434
查看评论