Automation · Bash Automation
Shell Expansion
Cheat sheet · https://pcornel.dk/topic.php?topic=5286
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 expansionshopt -s nullglob— empty glob handlingecho "${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