Created
May 24, 2012 16:03
-
-
Save MarkRoddy/2782429 to your computer and use it in GitHub Desktop.
Bash - Command Sub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command Substitution | |
Command substitution allows the output of a command to replace the command name. There are two forms: | |
$(command) | |
or | |
`command | |
Bash performs the expansion by executing command | |
$(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 pathname expansion are not performed on the results. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment