Bash - Expansion

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Expansion in Bash.

It's performed on the command line after it has been split into words. See Bash - Command Execution

There are seven kinds of expansion performed:

Advertising

3 - Order

The order of expansions is:

  • brace expansion,
  • tilde expansion,
  • parameter expansion,
  • variable expansion
  • arithmetic expansion
  • and command substitution (done in a left-to-right fashion),
  • word splitting,
  • and pathname expansion.

On systems that can support it, there is an additional expansion available:

  • process substitution.

4 - Word change

Only:

  • brace expansion,
  • word splitting,
  • and pathname expansion

can change the number of words of the expansion;

Other expansions expand a single word to a single word.

The only exceptions to this are the expansions of:

Advertising

5 - Documentation / Reference