shell variable interpolation?

Sam Couter sam at
Mon Nov 18 22:56:56 EST 2002

Steven Hanley <sjh at> wrote:
> All
> Okay so I am wondering if there is a better way to interpolate variables
> within a string in shell than I have worked out here.

bash has a builtin expression for indirection, but it's bash-specific:

${!variablename} will expand to the value of the variable named by
variablename. Sounds like something out of a Lewis Carrol story.

Eg, given:


Then ${!BAZ} will have the value "bar".
Sam "Eddie" Couter  |  mailto:sam at
Debian Developer    |  mailto:eddie at
                    |  jabber:sam at
OpenPGP fingerprint:  A46B 9BB5 3148 7BEA 1F05  5BD5 8530 03AE DE89 C75C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the linux mailing list