如何正确嵌套 Bash 反引号 [英] How to properly nest Bash backticks
本文介绍了如何正确嵌套 Bash 反引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要么我错过了一些强烈反对,要么反对似乎不适用于过多的程序员引用循环.
Either I missed some backlash or backlashing does not seem to work with too much programmer-quote-looping.
$ echo "hello1-`echo hello2-`echo hello3-`echo hello4```"
hello1-hello2-hello3-echo hello4
通缉
hello1-hello2-hello3-hello4-hello5-hello6-...
推荐答案
使用 $(commands)
代替:
$ echo "hello1-$(echo hello2-$(echo hello3-$(echo hello4)))"
hello1-hello2-hello3-hello4
$(commands)
与反引号的作用相同,但您可以嵌套它们.
$(commands)
does the same thing as backticks, but you can nest them.
您可能还对 Bash 范围扩展感兴趣:
You may also be interested in Bash range expansions:
echo hello{1..10}
hello1 hello2 hello3 hello4 hello5 hello6 hello7 hello8 hello9 hello10
这篇关于如何正确嵌套 Bash 反引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文