Lesson 1 of 0
In Progress

Command Substitution (expansion)

You can use the following expressions:

expression description
+ addition
- subtraction
/ division
* multiplication
** to the power of
% remainder – typically used for true false related to evens/odd determination

💡 It is important to note that you cannot use decimal numbers in bash and any outputs that result in decimal numbers will be truncated to the whole number. This is where the bc command will come into play but I’m not going to get too into it just yet. bc command is a “basic calculator” that will allow piping into it your expression like this: "scale=2; 9/2 | bc which will result in 4.50. The scale will determine how many decimal places it will use. It’s also good to know that exponents in bc use ^ instead of **.