Another environment
variable that can be set is the PATH variable which is used to
locate commands in directories in the order specified by the PATH
statement. The PATH variable is an environment variable by default.
For example
the hostname
command is located in the /usr/ucb directory and is used to
display the host's name. It can be executed by specifying entire
path with the command name
/usr/ucb/hostname. If you work with several commands
in that directory though, you can save a great deal of extra
typing by adding /usr/ucb to the path variable and then execute
the command by typing hostname
only.
Command Format
PATH=directory:directory:directory
Example
This example sets the
path to look through the /usr/bin, /usr/frame/bin, /usr/lib and
current directory (denoted by the . at the end of the statement)
when a user enters a command:
$ PATH=/usr/bin:/usr/frame/bin:/usr/lib:.
$ export PATH
$ echo $PATH
/usr/bin:/usr/frame/bin:/usr/lib:.
$
You can also add to
the existing path by typing the following:
$ PATH=$PATH:/usr/ucb
$ echo $PATH
/usr/bin:/usr/frame/bin:/usr/lib:.:/usr/ucb