UNIX, get environment variable UNIX, get environment variable unix unix

UNIX, get environment variable


You can do:

printenv VARIABLE_NAME


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.