如何正确嵌套Bash反引号 [英] How to properly nest Bash backticks

查看:263
本文介绍了如何正确嵌套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屋!

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