Reputation: 23
From the 《Bash Guide for Beginners》 :
3.4.5. Command substitution
Command substitution allows the output of a command to replace the command itself. Command substitution
occurs when a command is enclosed like this:
$(command)
or like this using backticks:
\`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.
franky ~> echo `date`
Thu Feb 6 10:06:20 CET 2003
When the old−style backquoted form of substitution is used, backslash retains its literal meaning except when
followed by "$", "`", or "\".
The first backticks 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.
In this passage, there is one sentence I don't understand.
The first backticks not preceded by a backslash terminates the command substitution.
Can you provide examples to explain it in more detail? Thank you very much!
Upvotes: 2
Views: 3483
Reputation: 648
The author meant the first not-escaped backtick.
Dummy example:
echo `command \` arg`
First the backtick between command and arg is escaped with backslash, so the substitution is closed by the last backtick.
Upvotes: 3