Value of an environment variable

If you wish to see the value of an environment variable the easiest way to do so is to print the contents of the variable in your shell. To do so you have to use the following command:

echo $var_name

If there is an environment variable defined named var_name then the above command will output its contents in standard output (your shell). If there is no variable with that name defined the above command will output an empty line. If you see var_name outputed in your shell you probably forgot to type in the $ sign before the name of your variable. Remember that echo simply echoes a string in standard output so if you do not specify that the string you typed is a variable ($ sign) then it will simply output your string.

Now if you do not exactly remember the name of your environment variable the easiest way to find out if it is defined or not would be to output all the environment variables defined and either move your way through the list like


or pipe the output to grep providing a part of the name of the variable like

printenv | grep name