首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在linux中使用backticks?

如何在linux中使用backticks?
EN

Stack Overflow用户
提问于 2015-07-28 07:01:21
回答 1查看 2.5K关注 0票数 2

来自“初学者指南”:

代码语言:javascript
复制
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.

在这段话中,有一句我不明白。

代码语言:javascript
复制
The first backticks not preceded by a backslash terminates the command substitution.

你能提供更详细的例子来解释吗?非常感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-28 07:33:38

作者指的是第一个没有逃脱的回击。

虚构的例子:

代码语言:javascript
复制
echo `command \` arg`

首先,命令和arg之间的反勾号用反斜杠转义,所以替换被最后一个反勾号关闭。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31669425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档