1
2
3
4
5
6
7
8
9
10
11
12
13
|
<h1 class="section">Shell Expansions</h1> <p>Expansion is performed on the command line after it has been split into <code>token</code>s. There are seven kinds of expansion performed: </p> <ul> <li> brace expansion </li>
<li> tilde expansion </li>
<li> parameter and variable expansion </li>
<li> command substitution </li>
<li> arithmetic expansion </li>
<li> word splitting </li>
<li> filename expansion </li>
</ul> <p>The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and filename expansion. </p> <p>On systems that can support it, there is an additional expansion available: <em>process substitution</em>. This is performed at the same time as tilde, parameter, variable, and arithmetic expansion and command substitution. </p> <p>After these expansions are performed, quote characters present in the original word are removed unless they have been quoted themselves (<em>quote removal</em>). </p> <p>Only brace expansion, word splitting, and filename expansion can increase 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 <code>"$@"</code> and <code>$*</code> (see <a href="special-parameters">Special Parameters</a>), and <code>"${<var>name</var>[@]}"</code> and <code>${<var>name</var>[*]}</code> (see <a href="arrays">Arrays</a>). </p> <p>After all expansions, <code>quote removal</code> (see <a href="quote-removal">Quote Removal</a>) is performed. </p> <ul class="section-toc"> <li><a href="brace-expansion" accesskey="1">Brace Expansion</a></li> <li><a href="tilde-expansion" accesskey="2">Tilde Expansion</a></li> <li><a href="shell-parameter-expansion" accesskey="3">Shell Parameter Expansion</a></li> <li><a href="command-substitution" accesskey="4">Command Substitution</a></li> <li><a href="arithmetic-expansion" accesskey="5">Arithmetic Expansion</a></li> <li><a href="process-substitution" accesskey="6">Process Substitution</a></li> <li><a href="word-splitting" accesskey="7">Word Splitting</a></li> <li><a href="filename-expansion" accesskey="8">Filename Expansion</a></li> <li><a href="quote-removal" accesskey="9">Quote Removal</a></li> </ul><div class="_attribution">
<p class="_attribution-p">
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>Licensed under the GNU Free Documentation License.<br>
<a href="https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html</a>
</p>
</div>
|