Bash Scripting

Automating everyday command-line work.

Bash Scripting is taught here in 12 lessons, running from Variables, quoting and exit codes through to A practical automation project. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.

TrackDevOps & Tooling
Lessons12
LevelBeginner to intermediate
Reading timeabout 3 hours
PrerequisitesHelpful, but not required: CI / CD

Lessons

  1. Variables, quoting and exit codesAssign and expand values safely, understand word splitting, and read the status a command returns.
  2. Conditionals and loopsBranch on files, strings and numbers, match patterns with case, and iterate over lines without breaking on spaces.
  3. Writing a robust scriptStrict mode, traps that clean up after a crash, and argument parsing that fails with a useful message.
  4. Shells, startup files and running scriptsInteractive versus script shells, bash versus sh, shebangs, executable bits, startup files, sourcing versus executing, and the shell option set.
  5. Functions, arrays and associative arraysFunction definition and return versus output, local variables, positional parameters and shift, indexed arrays, mapfile, and associative arrays for lookups.
  6. Parameter expansion and string manipulationDefault values and assignment forms, substring and length expansion, prefix and suffix removal with patterns, case conversion, and building paths and names safely.
  7. Files, redirection and here-documentsFile descriptors, redirecting stdout and stderr, appending and truncating, here-documents and here-strings, process substitution, and reading files line by line.
  8. Text processing: grep, sed and awk in scriptsgrep options and exit status, sed substitutions and in-place edits, awk fields and patterns, cut, sort and uniq, and choosing the right tool for the job.
  9. Process handling, signals and parallelismBackground jobs and wait, job control, signals and traps, timeouts, xargs -P, GNU parallel, and controlling concurrency without flooding a machine.
  10. Testing and linting shell scriptsShellCheck and fixing what it reports, shfmt formatting, bats for unit tests, testing with fixtures and temporary directories, and wiring checks into CI.
  11. Portability and POSIX shellWhat dash and busybox support, POSIX versus bashisms, portable arrays and local, testing against sh, and handling Windows paths and line endings.
  12. A practical automation projectRequirements and structure, logging and dry-run modes, configuration and environment, idempotent operations, locking to prevent double runs, and packaging a reusable tool.

More in DevOps & Tooling

Git Linux Docker Kubernetes Nginx CI / CD Ansible

FAQ

How long does the Bash Scripting course take?
It has 12 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Bash Scripting?
Not strictly. It helps to have read CI / CD first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Bash Scripting?
Continue with Ansible (3 lessons), the next course in DevOps & Tooling.

Last refreshed 2026-09-18.