Integer Operations

# echo $((1+1))
2

# echo $[1+1]
2

Non-Integer Operations

Because bash can only handle interger values you need to utilize the ‘bc’ command to get float values.
See example:

# echo $((17/4))
4

# echo 17/4 | bc -l
4.25000000000000000000

-l|–mathlib –> Define the standard math library

um die anzahl der nachkommastellen auszugeben/zu bestimmen bietet bc eine funktion scale

# echo "scale=4; 17/4" | bc -l
4.2500

Leave a Reply