Using variables and conditional statements in Bash
We covered a brief introduction to Bash scripting at the end of Chapter 4, An Introduction to the Terminal. In the previous section, we created a simple script that monitors the temperature of your computer's CPU in almost real time. While useful, this script, in particular, won't save you a lot of time, since you can use the sensors
command to do the same thing with almost the same amount of time. Bash really shines because of the fact that it has all the features you'd expect from an actual programming language, including if
statements and variables. Bash scripting is used by many administrators to simplify and automate tasks. Paired with cron, you can easily create scripts to automatically run, and with enough skill, completely set up a Linux computer from a bare installation of a distribution to a fully functioning system for a specific purpose.
Before we continue, recall two very important requirements for scripting....