什么是$(...)和`...`的区别 [英] What's the difference between $(...) and `...`
问题描述
作为标题指出的问题很简单:什么是以下两个前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屋!