巴什间接引用,其中一个变种引用多个 [英] Bash indirect reference where one var references multiple

查看:93
本文介绍了巴什间接引用,其中一个变种引用多个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图取消引用两个或包含在一个单一变量更多的变量,但我想不出如何做到这一点不EVAL:

I am trying to dereference two or more variables contained in a single variable but I can't think of how to do it without eval:

$:b=5
$:c=10
$:a='$b $c'
$:result=`eval echo $a`
$:echo $result
5 10

我希望做的相当的操作,让我'结果',所以我没有做一个eval。是否有可能解决由单一变量任何其他方式引用多个变量?我要做到这在bash

I'm looking to do the equivalent operation that gives me 'result' so I don't have to do an eval. Is it possible to resolve multiple variables referenced by a single variable any other way? I'm looking to do this in BASH

推荐答案

EVAL听起来挺吓人的......

eval sound quite scary...

这里是一个更好的解决方案:

here is a better solution:

<一个href=\"http://stackoverflow.com/questions/2914220/bash-templating-how-to-build-configuration-files-from-templates-with-bash\">Bash模板:怎样从猛砸模板建立配置文件

您只需要调整它了一点,所以它遵循你的语法。

you just have to tweak it a bit so it follows your syntax.

这篇关于巴什间接引用,其中一个变种引用多个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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