next up previous contents
Next: Shell Variables Up: Variables Previous: Variables   Contents

Environmental Variables

Environmental variables hold numbers and character strings and are typically used to customise the way the system works. For example, the variable PATH contains a list of all the directories the system should search when looking for a program file that matches the commands you type. By convention, environmental variables have names that are all upper case. To create the variable MYVAR, store the character string ``abc'' in it, print it out, and then delete it again, from the Bourne shell:-

MYVAR="abc"
export MYVAR
echo $MYVAR
unset MYVAR
To do the same thing from the C shell:-
setenv MYVAR "abc"
printenv MYVAR
unsetenv MYVAR
To list all the current variables, from either shell, type:-
env
Once created, an environmental variable persists until you delete it or logout. Any process you run, will see the same variables, which is normally what you want i.e. that all you jobs see the same customised environment.



P.D. Gronbech (IT Staff) 2015-10-02