Skip to content

Bash Scripting For Automation Textbook

A free, self-paced textbook in 8 chapters. Read a chapter, then drill it with the 120 companion flashcards using spaced repetition.

8 chapters · 120 cards · Updated

Chapters

  1. 1Foundations of Bash Scripting

    Bash, the Bourne Again SHell, is a Unix shell and command language written as a free software replacement for the original Bourne shell. It serves as the default login shell on mos...

  2. 2Variables, Expansion, Quoting, and Strict Mode

    A Bash variable is a named storage location for a value. Variables are assigned with NAME=value — critically, with no spaces around the = sign, because Bash treats VAR = value as a...

  3. 3Conditionals and Tests

    Conditional execution in Bash revolves around if, elif, else, and fi. The condition itself is a list of commands whose exit status determines the branch: zero is true and non-zero...

  4. 4Loops and Iteration

    Bash offers several ways to iterate. The most basic form is for name in list; do body; done, where the list may be a literal set of words, a glob, the output of a command substitut...

  5. 5Functions, Sourcing, and Command-Line Arguments

    Functions are defined in Bash with name() { commands; } or with the keyword form function name { commands; }. The body of a function executes in the same shell environment as the c...

  6. 6Arrays, Strings, Substitutions, and Arithmetic

    Bash supports both indexed arrays and associative arrays (dictionaries). Indexed arrays are declared with arr=(one two three) or by element with arr[0]=one, and individual elements...

  7. 7Input/Output, Redirection, and File Handling

    The read builtin is the primary way to ingest input. read -rp "Prompt: " answer reads a single line with a prompt and without backslash interpretation, while while IFS= read -r lin...

  8. 8Process Control, Scheduling, and Robust Practices

    A subshell, written ( commands ) or produced by backgrounding, runs its commands in a child of the current shell. Any changes to variables, the working directory, or shell options...

← Back to the Bash Scripting For Automation deck