Sample Header Ad - 728x90

What does `echo ${!a}` do and why?

0 votes
0 answers
80 views
The following bash script prints out c, but I'm not sure why.
a=b
b=c
echo ${!a}
I believe that !a will be converted to the last command which began with a, so in this case that would be a=b. This should mean that the last command is equivalent to the following.
echo ${a=b}
However, that prints b, not c. Is anyone able to explain why this is the case?
Asked by Abraham Murciano Benzadon (131 rep)
Mar 8, 2021, 03:36 PM