> For the complete documentation index, see [llms.txt](https://notes.eliasnorrby.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.eliasnorrby.com/bash/variable-by-name.md).

# Reference variable by name

In bash, one can use the syntax `${!varname}` to expand the value of the variable with the name `$varname`.

```bash
PARAM_REV=master
varname=PARAM_REV
echo $varname
# PARAM_REV
echo ${!varname}
# master
```

Source:

* `LESS='-p Parameter Expansion' man bash`
