Creating a string variable name from the value of another string

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

#!/bin/bash

CONFIG_OPTION="VENDOR_NAME"
CONFIG_VALUE="Default_Vendor"

printf -v "$CONFIG_OPTION" "%s" "$CONFIG_VALUE"

# Don't believe me?
echo "$VENDOR_NAME"

Leave a Comment