Language basics
26 steps in 9 sets of Bash.
Bash is the language everyone uses and almost nobody studies. It runs your CI, your deploys, your dotfiles and the glue between every tool you own, and it is old enough that its sharp edges are load-bearing: quoting decides whether a filename with a space survives, an exit code decides whether a pipeline lies to you, and the difference between $@ and $* has broken real deployments. Studying it for a few hours repays a decade of copy-pasted incantations.
This tour covers the shell as a language: expansion and quoting, the test and case constructs, loops over words and lines, real arrays, functions, and the pipes and redirections that compose small tools into big answers. grep, sed and awk get a set of their own, and the safety set teaches the prelude every serious script starts with. Every seed parses under bash -n and passes shellcheck before it reaches you.
Variables & quoting
- Variables & quotingAssignment, expansion, and the quoting that keeps words whole.
- Parameter expansionThe brace toolkit: length, trims, defaults and substitution.
- ArithmeticInteger math lives inside double parentheses.
Conditionals
- if & [[ ]]Branching on comparisons, globs and the filesystem.
- caseOne value against many patterns, first match wins.
- Exit codesZero is success, everything else is failure, and && || route on it.
Loops
- for loopsThree shapes: a word list, a C-style counter, a generated sequence.
- while readThe line-by-line loop that processes streams.
- Brace expansionThe shell generates strings before anything runs.
Arrays
- ArraysReal lists, if you quote them right.
- Associative arraysString keys via declare -A.
- Array slicingSlices, joins and indices from the expansion syntax.
Functions
- FunctionsArguments by position, locals by declaration, results by echo.
- Command substitutionA command's output, used as a value.
- Script argumentsWhat $@, $# and shift do with a command line.
Pipes & redirection
- Pipes & filtersSmall tools composed into one stream.
- RedirectionWhere output goes: files, appends, stderr and heredocs.
- Process substitutionA command's output, standing in for a file.
Text tools
Scripts & safety
- set -euo pipefailThe safety prelude, and cleanup that always runs.
- getoptsFlag parsing the built-in way.
- mktemp & trapPrivate scratch space that cleans itself up.
Encore
- log_summary.shA log triage in pure shell: buckets, top paths, the slow tail.
- backup_rotate.shKeep the newest three backups, delete the rest, prove it.