什么是$(...)和`...`的区别 [英] What's the difference between $(...) and `...`

查看:95
本文介绍了什么是$(...)和`...`的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题指出的问题很简单:什么是以下两个前pressions之间的区别

  $(...)
``...

例如,有两个变量测试1 测试2 不同?

 测试1 = $(LS)
测试2 =`ls`


解决方案

的结果是一样的,但较新的$()语法更加清晰,更易于阅读。至少加倍的努力巢时。嵌套不容易与旧的语法,但能正常工作与新的。

比较:

  $回声$(LS $(PWD))

  $`呼应LS \\`PWD \\``

您需要转义嵌入反引号,所以这是相当多这两个类型更为复杂和阅读。

根据此页面,还有如何至少有一个微小的差别他们对待嵌入式双反斜线。

The question is as simple as stated in the title: What's the difference between the following two expressions?

$(...)
`...`

For example, are the two variables test1 and test2 different?

test1=$(ls)
test2=`ls`

解决方案

The result is the same, but the newer $() syntax is far clearer and easier to read. At least doubly so when trying to nest. Nesting is not easy with the old syntax, but works fine with the new.

Compare:

$ echo $(ls $(pwd))

versus:

$ echo `ls \`pwd\``

You need to escape the embedded backticks, so it's quite a lot more complicated to both type and read.

According to this page, there is at least one minor difference in how they treat embedded double backslashes.

这篇关于什么是$(...)和`...`的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆