GNU Info

Info Node: (bashref.info)Command Substitution

(bashref.info)Command Substitution


Next: Arithmetic Expansion Prev: Shell Parameter Expansion Up: Shell Expansions
Enter node , (file) or (file)node

Command Substitution
--------------------

   Command substitution allows the output of a command to replace the
command itself.  Command substitution occurs when a command is enclosed
as follows:
     $(COMMAND)

or
     `COMMAND`

Bash performs the expansion by executing COMMAND 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 `$(cat
FILE)' can be replaced by the equivalent but faster `$(< FILE)'.

   When the old-style backquote form of substitution is used, backslash
retains its literal meaning except when followed by `$', ``', or `\'.
The first backquote not preceded by a backslash terminates the command
substitution.  When using the `$(COMMAND)' form, all characters between
the parentheses make up the command; none are treated specially.

   Command substitutions may be nested.  To nest when using the
backquoted form, escape the inner backquotes with backslashes.

   If the substitution appears within double quotes, word splitting and
filename expansion are not performed on the results.


automatically generated by info2www version 1.2.2.9