簡體   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