Mathematical operation
operation
2023-09-14 09:07:49 时间
(1)Using let
let result=2+1
let result=2-1
let result=2*1
let result=2/1
(2) Using bracket
echo $(($p1+$p2))
OR sum=$(($p1+$p2))
echo $sum
(3) Using ` and expr
1.乘号(*), 左括号( ( ) , 右括号( ) )必须使用反斜杠(\)转义。
2.expr右边以及运算符和括号的两边必须有空格
result=`expr 4 + 2`
result=`expr 4 - 2`
result=`expr 4 \* 2`
result=`expr 4 / 2`
result=`expr 4 % 2`
result=`expr \( 4 - 2 \) \* 2` (注意两项的综合运用)
相关文章
- A conflict in the working copy obstructs the current operation
- Failed to execute operation: No such file or directory(systemctl enable iptables.service)
- JS魔法堂:再识Bitwise Operation & Bitwise Shift
- C++ code:位操作实例(bit operation example)
- filter operation implementation in Gateway framework
- filter operation implementation in Gateway framework
- filter operation implementation in Gateway framework
- 已解决sqlalchemy.exc.OperationalError: (pymssql.OperationalError) (1946, b“Operation failed. The index
- 原子操作(atomic operation)
- Error disabling address space randomization: Operation not permitted
- 【虚拟机】解决“operation inconsistent with current state”