1.Use the value assignment statement:
Format:
LetValue assignment expression
【Tip] The Value assignment expression can be omitted as follows:((Value assignment expression))
Example: Give the independent variableIAdd1
Let I = I + 1
Or
(I = I + 1) ----------- High Efficiency
Or
#! /Bin/bash
Let "T1 = (A = 5 + 3, B = 7-1, C = 15-4 ))"
Echo "T1 = $ T1, A = $ A, B = $ B"
2.UseExprCommand:
Example: Give the independent variableIAdd1
I = 'expr $ I + 1' ----------- Low Efficiency
3.UseBCCommand:
BCYesUNIXIt can also be used under the command line:
Example: Give the independent variableIAdd1
I = 'echo $ I + 1 | bc' ----------- Low Efficiency
※BecauseBCSupports scientific computing, so this method is very powerful.
4. integer operations can also be directly calculated using integer variables
example:
typeset-I a = 1 B = 3
A = a + B ----------- High Efficiency
echo $ A
result is 4