shell indirect variable references in two ways

Copyright notice: reproduced please indicate the source. https://blog.csdn.net/u010720408/article/details/91392789

Sometimes we need to use the value of a variable to refer to the demand value as the value of the variable, ie A = "B", then there is one variable B = "value", the need to obtain access to "value" this value by A ;

There are two ways

#准备
v1="v2"
v2="hellow"

A value = $ {! Varname} manner, i.e., $ {!}

v3=${!v1}

Two expr value = $$ varname way that is expr \ $$

eval v4=\$$v1

Example:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/u010720408/article/details/91392789