ENVIRONMENT VARIABLES

The behavior of your unix environment is controlled by the values of certain variables, called environment variables. For instance there is a variable named PATH which contains a list of directories. Here is the value of PATH in my unix account:
% printenv PATH
.:/home/yap/bin:/usr/local/bin:/opt/gnu/bin:/opt/java1.2/bin

Actually, I have greatly truncated the actual list of directories for this illustration. Note that the directory names are separated by colons, ":". Thus the first directory is "." (current directory), then "/home/yap", then "/usr/local/bin", etc. When you type a command to the unix shell, unix will look for the command by searching first in ".", then in ~/home/yap", etc.

E.g., if you type "javac Hello.java", then unix will look for "javac" (the java compiler) in this list of directories. In this case, it will find javac in the last directory in PATH (namely, /opt/java1.2/bin).

A useful trick is this. Suppose there are commands in a directory "/home/yap/lookup" that you want unix to search first, before any of the current list of directories. You can update your PATH variable this way:

% setenv PATH "/home/yap/lookup:`printenv PATH`"

This simply appends "/home/yap/java/bin" to the front of your current list search directories. NOTE: the argument "/home/yap/lookup:`printenv PATH`" creates a string value. The unusual thing is the substring

`printenv PATH`

which is really a request to unix to execute the command "printenv PATH", and substitute the result of that command into the string! Neat trick.