Interview Prep/Shell Scripting/Shells, scripts and execution

What are the main categories of shell expansion, in the order Bash performs them?

AdvancedConceptShells, scripts and execution
Answer
  1. Brace expansion: {a,b}, {1..10}
  2. Tilde expansion: ~, ~user
  3. Parameter and variable expansion, arithmetic expansion $(( )), command substitution $( ) and process substitution <( ), left to right
  4. Word splitting on IFS (unquoted results only)
  5. Pathname expansion (globbing) of unquoted *, ?, [...]
  6. Quote removal

Consequence: x={1..3}; echo $x prints {1..3}, because brace expansion happened before the variable was expanded. And "$var" skips steps 4 and 5, which is why quoting prevents most bugs.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Shells, scripts and execution