bash - Unix Sell script - variable subtitution inside another and concatenate values to the same variable -


i have below requirement concatenate value of variable own variable , create 1 array:

table=crs job=jobname gen_job_$table=generatedjob gen_job_$table=$job,${gen_job_${table}} echo ${gen_job_${table}} should give jobname,generatedjob 

i tried using eval function below:

eval gen_job_$table=$job,eval echo \$gen_job_$table 

however, not able display final result.

does have ideas?

you perhaps want consider using array situation (and recommend reading this page, however, if want dynamically build variable names possible. set variable name stored in variable use printf -v like

table=crs job=jobname holds_name="gen_job_$table" printf -v "$holds_name" 'generatedjob' 

then when want access variable name set in holds_name can use indirection:

printf '%s,%s\n' "$job" "${!holds_name}" 

using braces around variable name, if first character inside brace ! rest of word treated name of variable expanded find name of actual variable value should used.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -