1 1 3.5 Shell Expansions 1 ==================== 1 1 Expansion is performed on the command line after it has been split into 1 'token's. There are seven kinds of expansion performed: 1 1 * brace expansion 1 * tilde expansion 1 * parameter and variable expansion 1 * command substitution 1 * arithmetic expansion 1 * word splitting 1 * filename expansion 1
1 · Brace Expansion Expansion of expressions within braces. · Tilde Expansion Expansion of the ~ character. · Shell Parameter Expansion How Bash expands variables to their values. · Command Substitution Using the output of a command as an argument. · Arithmetic Expansion How to use arithmetic in shell expansions. · Process Substitution A way to write and read to and from a 1 command. · Word Splitting How the results of expansion are split into separate 1 arguments. · Filename Expansion A shorthand for specifying filenames matching patterns. · Quote Removal How and when quote characters are removed from 1 words. 1 1 The order of expansions is: brace expansion; tilde expansion, 1 parameter and variable expansion, arithmetic expansion, and command 1 substitution (done in a left-to-right fashion); word splitting; and 1 filename expansion. 1 1 On systems that can support it, there is an additional expansion 1 available: PROCESS SUBSTITUTION. This is performed at the same time as 1 tilde, parameter, variable, and arithmetic expansion and command 1 substitution. 1 1 After these expansions are performed, quote characters present in the 1 original word are removed unless they have been quoted themselves (QUOTE 1 REMOVAL). 1 1 Only brace expansion, word splitting, and filename expansion can 1 change the number of words of the expansion; other expansions expand a 1 single word to a single word. The only exceptions to this are the 1 expansions of '"$@"' (⇒Special Parameters) and '"${NAME[@]}"' 1 (⇒Arrays). 1 1 After all expansions, 'quote removal' (⇒Quote Removal) is 1 performed. 1