Take the 2-minute tour ×

In my bash script I have two variables CONFIG_OPTION and CONFIG_VALUE which contain string VENDOR_NAME and Default_Vendor respectively.

I need to create a variable with name $CONFIG_OPTION ie VENDOR_NAME and assign the value in CONFIG_VALUE to newly created variable.

How I can do this?

I tried


But I am getting an error on this line as

'./Build.bash: line 137: VENDOR_NAME="Default_Vendor": command not found'


share|improve this question
Though this question has not been asked the exact same way, there are multiple answers, for example: stackoverflow.com/a/7776409/27862 –  Pumbaa80 Dec 5 '12 at 5:16
@Pumbaa80 : This helped much. Thank you for the link. –  NeonGlow Dec 5 '12 at 5:57
add comment

1 Answer

up vote 6 down vote accepted

I know that nobody will mention it, so here I go. You can use printf!




# Don't believe me?


Incidentally, it's a rather fast method (just as fast as the declare method).

share|improve this answer
Thank you so much for a rather surprising one... [sadly, I don't understand how this works] :) –  NeonGlow Dec 5 '12 at 7:03
You can read help printf. The -v option to printf means that it should assign the formated string to the variable the name of which is given just after the -v option. –  gniourf_gniourf Dec 5 '12 at 7:11
Oh... Thank you for further explaining it for me. –  NeonGlow Dec 5 '12 at 7:18
add comment

Your Answer


