1.2 Getting Started

Authored by Atri

Bash scripting is a way to automate the execution of repetitive tasks via the command line.

Typically speaking, Bash scripts are merely sequences of commands written to a text file which can then be executed by the shell. Bash supports higher-level features common to most high-use programming languages such as 2.2 Variables, 2.5 Conditionals, 3.1 Loops, 3.3 Pattern Matching, and 3.4 Functions, among others. These will be explored later in their own sections.

Bash scripts are typically best suited for execution on MacOS and Linux, however they can run on windows when an appropriate shell emulator is present. For this it is recommended that you have WSL 2 installed with Ubuntu as your distribution (the documentation is written with this in mind). Alternatively, you may use a terminal emulator such as Git Bash (provided with Git) to execute commands manually.

Note

Windows has its own built-in analogs that accomplish the same task as Bash, such as Batch files, or PowerShell scripting. These may be explored at a later point, but for the scope of this module we will not go over these.

To ensure you are able to execute the example snippets provided by this notebook, please ensure that you have a code execution plugin installed and that the following snippet runs successfully:

echo Hello world!