shell variable interpolation?
Sam Couter
sam at couter.dropbear.id.au
Mon Nov 18 22:56:56 EST 2002
Steven Hanley <sjh at svana.org> 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:
$FOO="bar"
$BAZ="FOO"
Then ${!BAZ} will have the value "bar".
--
Sam "Eddie" Couter | mailto:sam at couter.dropbear.id.au
Debian Developer | mailto:eddie at debian.org
| jabber:sam at jabber.topic.com.au
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 : http://lists.samba.org/archive/linux/attachments/20021118/7363e522/attachment.bin
More information about the linux
mailing list