LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 901|回复: 3

backticks `` 和 $() 两个命令替换符的问题,急!!!

[复制链接]
发表于 2006-2-11 16:00:21 | 显示全部楼层 |阅读模式
bash# echo `echo \\`                   #
bash# echo $(echo \\)                   # \

有哪位大虾能告诉我,为何两者输出的结果不同,为何用``时候,会没有任何输出,先谢了!
发表于 2006-2-11 16:31:32 | 显示全部楼层
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.

从Bash手册上抄来的。以前还真没注意这个问题。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-2-11 18:02:58 | 显示全部楼层
Post by shannleon
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.

从Bash手册上抄来的。以前还真没注意这个问题。
多谢shannleon兄,

不过如你所说,The first backquote not preceded by a backslash terminates the command substitution.这句话让我有点模糊.而且我觉得这段话没说到重点.如果shannleon兄能够解释得更详细些,那感激不尽啊.

顶!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-2-12 19:07:43 | 显示全部楼层
自己顶顶顶顶!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表