Pcornel
Automation · Bash Automation

Shell Expansion

Cheat sheet · https://pcornel.dk/topic.php?topic=5286

Back to the Topic

Answer

Shell expansion is how Bash rewrites a command before running it: variables, globs like *.log, brace expansion {a,b}, tilde and arithmetic $(( )). Quoting controls which expansions happen.

Remember

  • Bash expands variables, globs, braces, tilde and arithmetic before running.
  • Double quotes stop word splitting and globbing.
  • Unmatched globs stay literal unless nullglob is set.

First checks

  • echo {1..3} — brace expansion
  • shopt -s nullglob — empty glob handling
  • echo "${var//old/new}" — parameter expansion

Verify in this order

text → expansions → final words

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5286

Confirmation

Confirm action

Continue?