mirror of
https://github.com/dylanaraps/pure-bash-bible.git
synced 2025-03-14 05:39:37 +01:00
32 lines
456 B
Plaintext
32 lines
456 B
Plaintext
# ARITHMETIC
|
|
|
|
## Simpler syntax to set variables
|
|
|
|
```shell
|
|
# Simple math
|
|
((var=1+2))
|
|
|
|
# Decrement/Increment variable
|
|
((var++))
|
|
((var--))
|
|
((var+=1))
|
|
((var-=1))
|
|
|
|
# Using variables
|
|
((var=var2*arr[2]))
|
|
```
|
|
|
|
## Ternary Tests
|
|
|
|
```shell
|
|
# Set the value of var to var2 if var2 is greater than var.
|
|
# var: variable to set.
|
|
# var2>var: Condition to test.
|
|
# ?var2: If the test succeeds.
|
|
# :var: If the test fails.
|
|
((var=var2>var?var2:var))
|
|
```
|
|
|
|
<!-- CHAPTER END -->
|
|
|