Linux的accent-grave命令有什么作用?

Linux的accent-grave命令有什么作用?

在 bash shell (A) 中,输入`(accent-grave) 将启动另一个 shell 提示符 (B)。 B 中输入的任何命令的输出都是 A 的命令。

$ `
> whoami`
-bash: Joe: command not found

(如果我的用户名是 Joe。)

$ man `
> `
What manual page do you want?

有没有这方面的手册页,最好有一些例子?

答案1

它在 bash 手册中。搜索backquote(替换)

When  the  old-style  backquote form of substitution is used, backslash
retains its literal meaning except when followed by $, `,  or  \.   The
first backquote not preceded by a backslash terminates the command sub‐
stitution.  When using the $(command) form, all characters between  the
parentheses make up the command; none are treated specially.

Command substitutions may be nested.  To nest when using the backquoted
form, escape the inner backquotes with backslashes.

我发现$()更容易使用,尤其是在嵌套东西时。

相关内容