开发者

how to disable variable expansion when using bash "eval"

hi I have following propertie file (something.properties)

SERVER1_PROPERTY1=123    
SERVER1_PROPERTY2=${SERVER1_PROPERTY1}/123

and following bash script fetching one of the properties:

#!/bin/bash

. something.properties

SRV="SERVER1"

eval PROPERTY2=\$开发者_如何学运维${SRV}_PROPERTY2

echo $PROPERTY2

the result is:

123/123

but I want it to be

${SERVER1_PROPERTY1}/123

How can I achieve this?


The expansion is done when you source the file (. something.properties).

Write SERVER1_PROPERTY2='${SERVER1_PROPERTY1}/123' in your properties files to disable expansion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜