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:

  • brace expansion
  • tilde expansion
  • parameter and variable expansion
  • command substitution
  • arithmetic expansion
  • word splitting
  • filename expansion

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.


Published under the terms of the GNU General Public License Design by Interspire

AltStyle によって変換されたページ (->オリジナル) /