BASH: Accessing the value of the name of an environment variable passed in $1

view full story

http://www.linuxforums.org – Hi, doing exercises in A Practical Guide to Linux Commands, Editors, and Shell Programming by Mark G. Sobell. One of the exercises involves a script that is passed in the name of an environment variable. So lets say I have an environment variable $test that I exported with value "testing". So lets say the script is named foobar, and is invoked: foobar test So now the environment variable name test is in $1. But how do I access the actual value of $test, which is "testing", in bash? I tried doing something like: value=$("echo \$$1") which seems way too hackish. Am I missing something simple here? Also, later, the script adds some values to this $test environment variable how do I export the new $test variable value in bash? (HowTos)