Bash Cheatsheet

Power user.

Overview

Bash is the default shell on most Linux systems and the lingua franca of operations scripting. The features that make Bash powerful (pipelines, parameter expansion, process substitution, job control) also make it dangerous when used naively (word splitting on unquoted variables, silent failures without -e, unset-variable bugs without -u). Fluency means knowing both the powerful patterns and the defensive incantations that prevent the patterns from biting.

The approach

The practical approach is set -euo pipefail at the top of every script (exit on error, unset variable, or pipe failure), quote every variable expansion ("$var" not $var) to avoid word-splitting bugs, use ${var:-default} for compact defaults, prefer arrays over space-separated strings to avoid IFS hacks, and run shellcheck in CI to catch bugs before they ship.

Why this compounds

Bash fluency compounds across operations. Each script captures operational knowledge that future operators reuse; each defensive pattern (set -euo pipefail, quoting, shellcheck) prevents bug classes the team would otherwise hit repeatedly. After a year of disciplined use, the team has a script library that survives team changes.

Bash fluency is an operational discipline that pays off across years. Nova AI Ops integrates with operations telemetry, surfaces script patterns, and supports the team’s automation discipline.