繁体   English   中英

如何在Linux Shell中使用反引号?

[英]How to use backticks in linux shell?

摘自《 Bash初学者指南》:

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`

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM