After a grueling introduction to the world of wildcards and regexes for searches, we're going to move on to being able to perform some basic mathematical operations at the console. If you haven't already tried, what happens when you run something like the following in the Bash shell? Does it look like this?
$ 1*5
1*5: command not found
Command not found? Certainly, we know the computer can do math, but clearly Bash is unable to interpret mathematical operations in this way. We have to ensure that Bash is able to interpret these operations correctly through the use of:
- The expr command (antiquated)
- The bc command
- POSIX Bash shell expansion
- Another language/program to do the dirty work
Let's try again, but using the POSIX Bash shell expansion:
$ echo $((1*5))
5
We got the expected answer of 5, but where does...