[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5 Shell Expansions

Expansion is performed on the command line after it has been split into tokens. There are seven kinds of expansion performed:

3.5.1 Brace Expansion  Expansion of expressions within braces.
3.5.2 Tilde Expansion  Expansion of the ~ character.
3.5.3 Shell Parameter Expansion  How Bash expands variables to their values.
3.5.4 Command Substitution  Using the output of a command as an argument.
3.5.5 Arithmetic Expansion  How to use arithmetic in shell expansions.
3.5.6 Process Substitution  A way to write and read to and from a command.
3.5.7 Word Splitting  How the results of expansion are split into separate arguments.
3.5.8 Filename Expansion  A shorthand for specifying filenames matching patterns.
3.5.9 Quote Removal  How and when quote characters are removed from words.

The order of expansions is: brace expansion, tilde expansion, parameter, variable, and arithmetic expansion and command substitution (done in a left-to-right fashion), word splitting, and filename expansion.

On systems that can support it, there is an additional expansion available: process substitution. This is performed at the same time as parameter, variable, and arithmetic expansion and command substitution.

Only brace expansion, word splitting, and filename 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 "$@" (see section 3.4.2 Special Parameters) and "${name[@]}" (see section 6.7 Arrays).

After all expansions, quote removal (see section 3.5.9 Quote Removal) is performed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 3, 2002 using texi2html