Skip to content
The Bash Insectarium

/static/insetario/en/inseto/param-indireta/

Menu

BSH-013 · Parameters

${!var}

The variable that points at another: it expands the name stored inside it.

Indirection: if casta=rainha and rainha="põe os ovos", then ${!casta} returns "põe os ovos". The shell reads the name inside the variable and expands that other name.

It is the piece for improvised tables, from before associative arrays. In modern bash, declare -n creates true references; in zsh the same gesture is written ${(P)var}.

$ rainha="põe os ovos"
$ casta=rainha
$ echo "${!casta}"
põe os ovos
A name that carries another name on its back.