Basics
Bash can be learned like any other programming language. It’s got an environment (Unix or Linux), a kind of standard library (any CLI-driven program installed on the system), variables, control flow (loops, testing, and iteration), interpolation, a few built-in data structures (arrays, strings, and booleans – sort of), and more.
This entire book assumes that you’re a software developer and, therefore, know how to program, so rather than teach you about these standard programming-language features, we’ll simply show you what they look like in Bash, along with some advice on idiomatic use (or common misuse).
Variables
Like any programming language, Bash has variables that can either be empty or set to a value. Unset variables are simply “empty,” and Bash will happily use them without panicking unless you set the -u
(error on unset variables) option via set -u
.
Setting
To set a variable, use the equals sign.
FOOBAR...