linux - Could we do dynamic replace in bash shell? -


here have 2 vars in bash shell

id="abc"  id_string="here [${id}]" 

is there approach dynamic replace var ${id} "abc" in id_string , echo concole?

if understand question correctly id_string variable contains literal string ${id} when echoed screen , isn't assigned way show in question - assigning way have in question using double quotes means id_string variable never contains literal string ${id} because double quotes variable replacement done assigned. first: literal string ${id} id_string need use single quotes. , second: need reevaluate id_string echoed. (the $ bash prompt):

$ id=abc $ echo $id abc  $ id_string='here [${id}]' $ echo $id_string here [${id}]  $ eval echo $id_string here [abc]  $ echo $id, $id_string, `eval echo $id_string` abc, here [${id}], here [abc] 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -