summaryrefslogtreecommitdiff
path: root/devdocs/bash/command-substitution.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/bash/command-substitution.html
new repository
Diffstat (limited to 'devdocs/bash/command-substitution.html')
-rw-r--r--devdocs/bash/command-substitution.html12
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/bash/command-substitution.html b/devdocs/bash/command-substitution.html
new file mode 100644
index 00000000..d7993680
--- /dev/null
+++ b/devdocs/bash/command-substitution.html
@@ -0,0 +1,12 @@
+<h1 class="subsection">Command Substitution</h1> <p>Command substitution allows the output of a command to replace the command itself. Command substitution occurs when a command is enclosed as follows: </p>
+<div class="example"> <pre class="example">$(command)
+</pre>
+</div> <p>or </p>
+<div class="example"> <pre class="example">`command`
+</pre>
+</div> <p>Bash performs the expansion by executing <var>command</var> in a subshell environment and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution <code>$(cat <var>file</var>)</code> can be replaced by the equivalent but faster <code>$(&lt; <var>file</var>)</code>. </p> <p>When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by ‘<samp>$</samp>’, ‘<samp>`</samp>’, or ‘<samp>\</samp>’. The first backquote not preceded by a backslash terminates the command substitution. When using the <code>$(<var>command</var>)</code> form, all characters between the parentheses make up the command; none are treated specially. </p> <p>Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes. </p> <p>If the substitution appears within double quotes, word splitting and filename expansion are not performed on the results. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Command-Substitution.html" class="_attribution-link">https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html</a>
+ </p>
+</div>