indirect expansion

The bash form ${!name}, which reads the value of the variable whose name is stored in name.

In more detail

If name holds prod_host, ${!name} gives the value of prod_host, the safe replacement for eval when choosing a variable at run time. It only reads; use a nameref to write.

Example

name="${env}_host"; echo "${!name}"

Related terms

Taught in

References