Bash ${!variable}

bash

Solution

That is a short form for indirect references.

$ foo=bar
$ bar=bas
$ echo ${!foo}
bas

The seemingly similar construction ${!foo*} expands to the names of all variables whose name begin with foo:

$ foo1=x
$ foo2=y
$ echo ${!foo*}
foo1 foo2

Problem

I am scratching my head on this one, can't find the bash reference talking about it. In the code below ``` host_color=${uphost}_host_color host_color=${!host_color} ``` What is the second line doing ? what does the !operator do in this case ?

Original source