相关疑难解决方法(0)

究竟反斜杠在反引号内如何工作?

Bash常见问题解答

反引号内的反斜杠(\)以非显而易见的方式处理:

 $ echo "`echo \\a`" "$(echo \\a)"
 a \a
 $ echo "`echo \\\\a`" "$(echo \\\\a)"
 \a \\a
Run Code Online (Sandbox Code Playgroud)

但是,FAQ并未分解导致这种差异的解析规则。man bash我发现的唯一相关报价是:

当使用旧式的反引号形式的替换时,反斜杠保留其字面意思,除非后面是$,`或。

The "$(echo \\a)" and "$(echo \\\\a)" cases are easy enough: Backslash, the escape character, is escaping itself into a literal backlash. Thus every instance of \\ becomes \ in the output. But I'm struggling to understand the analogous logic for the backtick cases. What is the underlying rule and how does the observed output follow …

bash escaping backslash backticks

11
推荐指数
1
解决办法
313
查看次数

标签 统计

backslash ×1

backticks ×1

bash ×1

escaping ×1