Shell Scripting
Master bash scripting from quoting and expansion through awk, error handling and CLI design β ending in four production-grade projects.
beginner level
7 lessonsMaster terminal commands, shell translation pipelines (AST), execution triggers (execve), and octal permission flags mathematically.
How bash actually stores values, the difference between a shell variable and an environment variable, and why a child process cannot see what you just set.
The single largest source of shell bugs, resolved: what the shell does to your text before the command ever runs, and why every unquoted variable is a latent failure.
Master parameter arrays ($1, $#), whitespace boundaries, shift operations, and system exit code lookup tables.
Why `if` tests an exit status rather than a boolean, the real differences between `[ ]` and `[[ ]]`, and every file test operator worth knowing.
Every loop form bash offers, the arithmetic and C-style variants people forget, and the iteration mistakes that quietly process the wrong things.
Store lists and lookup tables without resorting to space-delimited strings, and learn the expansion rules that make arrays safe where plain variables are not.
intermediate level
9 lessonsWhy bash variables are global by default, the two ways to get data out of a function, and the scoping rules that make shell functions behave unlike every other language you know.
Wire file descriptors deliberately: why `2>&1` order matters, how here-docs generate config, and why a pipeline loses your variables.
grep, cut, sort, uniq, tr and find β the filters that compose into a pipeline, and the flags that matter when the data is real.
Two small languages that replace most log-processing scripts: awk's record model and sed's line editor, with the idioms that actually come up in production.
The one correct `while read` idiom, why every variation of it loses data, and how to handle filenames that contain spaces, backslashes and newlines.
Why `set -euo pipefail` is necessary, why it is not sufficient, and the specific constructs where it silently stops protecting you.
Turn `set -x` into a readable timeline, trace only the section you care about, and build logging that survives cron and CI where you cannot watch the terminal.
Split a growing script into sourceable libraries without namespace collisions, resolve paths reliably regardless of where the script is invoked from, and know when to stop using bash.
Build a production backup tool with rotation, integrity verification, and a restore path you have actually tested β the project that proves you can write shell people depend on.
advanced level
10 lessonsParse flags properly, write usage that doubles as documentation, and give your script the interface conventions every other Unix tool follows.
Run work concurrently and collect the results, handle Ctrl+C without leaving orphans, and know why a script that ignores SIGTERM breaks every deploy that uses it.
Why a script that works in your shell fails at 3am under cron, and the four defences every scheduled job needs before it goes anywhere near production.
Drive fleets over SSH without your loop eating its own input, move data with rsync safely, and turn curl plus jq into a reliable API client.
Turn raw logs into a ranked answer, decide what genuinely deserves a page, and deliver alerts that carry enough context to act on.
Let a static analyser find your quoting bugs, adopt a style that survives code review, and know exactly which constructs break when `/bin/sh` is not bash.
Write real tests for shell code with bats, handle credentials without leaking them into logs or process lists, and recognise the point where another language is the professional choice.
Build the monitoring agent you would actually trust on-call: plugin-style checks, flap damping, deduplicated alerts, recovery notices, and a dead-man switch.
Build a deploy tool with atomic release switching, health-gated cutover, and a rollback that works when everything else has failed β the script that earns production access.
The capstone: ingest heterogeneous logs, correlate them into a timeline, detect anomalies against a baseline, and emit a postmortem-ready incident report.
πΊοΈ Beginner β Expert Roadmap
3 stages with prerequisites and a concrete mastery check at each.
π― What You'll Learn
- β’ Quote every expansion correctly β the single largest source of shell bugs.
- β’ Write robust command-line scripts to automate configuration, backup, and diagnostic routines.
- β’ Use conditional logic, loops and arrays to audit files and process logs line-by-line.
- β’ Apply strict mode and know the five contexts where set -e stops protecting you.
- β’ Replace multi-stage pipelines with a single awk program.
- β’ Build proper CLIs with getopts, subcommands and conventional exit codes.
- β’ Schedule unattended work that survives cron, with locking and timeouts.
- β’ Pass ShellCheck cleanly and know what breaks under /bin/sh.
- β’ Ship four production-grade projects: backup, monitoring, deployment and log forensics.
- β’ Judge when a script has outgrown bash β and hand it to Python deliberately.
πΌ Interview Readiness
Once you reach the end of this path, test your engineering knowledge against real questions asked by top technical teams: