August 20, 2004

Shell variable interpolation

Alright, this is fairly geeky, but I'd like to know if there is a better way of doing this.

Something I love about perl is how many places it lets you interpolate. Being used to this flexibility, I wanted to do something similar in a shell script (in particular, my .bash_profile). This is my first stab at it:

To interpolate shell variables into a new variable:

abc=`eval echo \\$$a$b$c`

As a side, BASH allows you to do single variable interpolation by: ${!var} .

Please let me know if there is a better way!

Posted by brainsik at August 20, 2004 07:33 AM | TrackBack
Comments