Programming By Stealth is a podcast created by Bart Busschots and me (Allison Sheridan). Bart is the instructor of the class to learn to program and I am the student in the audio podcast. Bart writes tutorial shownotes which are published at https://pbs.bartificer.net and you can listen to the show in your podcatcher of choice, or via the shownotes, or via Programming By Stealth at www.podfeet.com/...
Bart is teaching a mini-series on shell scripting and in PBS 146 included this challenge:
If you’d like to put your Bash skills to the test, try writing a script that accepts a whole number as an input, either as the first argument or from a user prompt, then prints out the standard n-times multiplication tables to the screen, i.e., if you give the number 3, the output should be:
1 x 3 = 3
2 x 3 = 6
3 x 3 = 9
4 x 3 = 12
5 x 3 = 15
6 x 3 = 18
7 x 3 = 21
8 x 3 = 24
9 x 3 = 27
10 x 3 = 30
You should use the bc (basic calculator) terminal command to do the arithmetic. You’ll need to teach yourself how to use it either with the help of your favourite search engine, or the man page (man bc).
For bonus credit, update your script to allow the user to specify how high the table should go, defaulting to 10 like above.