In Linux, the bc command stands for Basic Calculator (or sometimes referred to as Binary Calculator).
It is a command-line utility that provides an arbitrary-precision mathematical scripting language. While it can be used for simple addition and subtraction (as you just did in the script), it is actually a quite powerful tool that supports:
- Floating-point numbers: Handling decimals (using the
scalevariable). - Variables and functions: Allowing you to write complex mathematical logic.
- Logic statements: Such as
ifstatements and loops (for,while).
In the context of Shell scripting, it is the standard way to perform calculations that involve decimals because the built-in Bash arithmetic $((...)) only supports integers.
Great job on completing the script! You can now move on to the next part of the lab.