6.8. ArithmeticTo perform an arithmetic operation in Bash, you simply put the operation inside a double set of parentheses (Figure 6-24).
Common numeric operations include those listed in Figure 6-25.
Integer arithmetic is faster than floating-point arithmetic. If you know your variable will always be an integer (like a counter or array index), you can use the declare built-in to declare it to be an integer (Figure 6-26).
After we look at some simple conditional expressions, we'll combine them into a simple math script. |