摘自《初学者练习指南》:

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.

在这篇文章中,有一句话我不明白。
The first backticks not preceded by a backslash terminates the command substitution.

你能举些例子详细解释一下吗?
非常感谢!

最佳答案

作者的意思是第一个没有逃过一劫。
虚拟示例:

echo `command \` arg`

首先,command和arg之间的反斜杠用反斜杠转义,因此替换由最后一个反斜杠关闭。

关于linux - 如何在Linux Shell中使用反引号?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31669425/

10-13 08:52