There are two ways of substituting the standard output of a command for a part of a word or a full word. In the first (new) form, the command is enclosed in parentheses and preceded by a dollar sign: $(...). In the second (old) form, the command is enclosed within backquotes: ` ...` . If the second form is used, the string between the backquotes is processed for special quoting characters before the command is executed (see the section “Quoting metacharacters”). Trailing newlines are removed for both forms.
The command substitution $(cat file) can be replaced by the equivalent but faster $(<file). Command substitutions on built-in commands which do not perform I/O redirection are carried out without a separate process being spawned.
Example
The following command can be used to edit all the files in a directory which have names ending in .c and contain the string include:
for name in $( grep -l include *.c ) do edt $name done
Example
This command will print the second-last parameter in a shell script:
eval print \$$(( $#-1 ))