Scripting with Bash
Bash (Bourne Again SHell) is one specific shell implementation that has gained widespread popularity and is the default shell for many Linux distributions. Bash scripts can automate repetitive tasks, handle file and text manipulation, control job scheduling, and much more.
Note
While Bash is a specific shell, the term “shell” is more generic and encompasses other shell implementations.
A Bash script is a plain text file that contains a series of commands. These scripts can be used to automate entire workflows and complex processes that you’d otherwise have to perform command by command on the command line.
To create a Bash script, use a text editor to write your script, save it with any name, and give it the .sh
extension. For example, you might name your script, script.sh
. You can also use Vim like so:
Figure 6.6: Creating a Bash script
In Figure 6.6, we are creating a Bash script using vi
, and then...