UNIX, get environment variable
type the following command in terminal, it will display all the list of environment variables
printenv
now print the wanted variable like this:
echo $VARIABLENAME
Do you mean something like this:
ENV() { printf 'echo $%s\n' $1 | sh}
This works in plain old Bourne shell.