Skip to content

Commit 975d9f7

Browse files
authored
(()) for mathemitical operation
1 parent e6741d9 commit 975d9f7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

learningbash.md

+12
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,15 @@
120120
- echo `$?`: to print the exit status of the last executed command.
121121
- `test 1 -eq 1`, followed by echo `$?`: will print 0.
122122
- `test 1 -eq 1` is same as `[ 1 eq 1 ]`, using two brackets, we are allowed to use more operators: `[[ 1 = 1 ]]`
123+
- `(())` are used to do matematical calculation:
124+
```
125+
f=$((1+1))
126+
((c=3+5))
127+
echo $f
128+
echo "c equal to $c"
129+
```
130+
- for floating point calculatio, we need to use the `bc` command as follows:
131+
```
132+
d=$(echo "1.2 + 1.3" | bc)
133+
echo "d equal to $d"
134+
```

0 commit comments

Comments
 (0)