/media/bill/PROJECTS/System_maintenance/Linux/variable read from file as a string.txt www.BillHowell.ca 18Oct2019 initial +-----+ variable_eval_test() { echo "d_Lucas= $d_Lucas" a='/*_file_insert_path "$d_Lucas""context/waiver, copyright.txt"' echo "a= $a" b=$( echo "$a" | sed 's#\/\*_file_insert_path \"\(.*\)\"#\"\1\"#' ) a12=$( eval "echo $b" ) echo "a12= $a12" } ******************************************* ************ 18Oct2019 search "Linus bash and how do I evaluate a variable name read in as a string?" +-----+ https://stackoverflow.com/questions/1921279/how-to-get-a-variable-value-if-variable-name-is-stored-as-string#1921337 You can use ${!a}: var1="this is the real value" a="var1" echo "${!a}" # outputs 'this is the real value' This is an example of indirect parameter expansion: The basic form of parameter expansion is ${parameter}. The value of parameter is substituted. If the first character of parameter is an exclamation point (!), it introduces a level of variable indirection. Bash uses the value of the variable formed from the rest of parameter as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of parameter itself. edited Mar 22 at 12:41 answered Dec 17 '09 at 12:09 Phil Ross 21.3k99 gold badges6363 silver badges7272 bronze badges 3 This works for me in OSX bash, but not debian? On debian I get Bad substitution error. – 23inhouse Aug 8 '13 at 3:16 11 @23inhouse Are you running your script using /bin/sh? If so, try using /bin/bash instead. From Debian Squeeze onwards, /bin/sh was changed to be a symlink for dash instead of bash. dash doesn't support this particular syntax and will output a Bad substitution error. – Phil Ross Aug 8 '13 at 13:56 8 Is there a way to make this work for a variable name that belongs to an array? – Loupax Jan 15 '14 at 12:05 Works on ubuntu with bash – Sergey P. aka azure Sep 25 '14 at 12:13 1 @DoronShai This is an example of indirect parameter expansion, documented in the Bash Reference Manual at gnu.org/software/bash/manual/html_node/… – Phil Ross May 28 '15 at 11:52 see "/media/bill/PROJECTS/bin/variable eval.sh" # enddoc