[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 2

hash Command


Remembers or reports command path names.


To Add the Path of a Command to the Path Name List:

hashCommand ... ]

To Clear Path Name List:

hash -r


The hash command affects the way the current shell remembers a command's path name, either by adding a path name to a list or purging the contents of the list.

When no parameter or flag is specified, the hash command reports to standard output the contents of the path name list. The report includes the path name of commands in the current shell environment that were found by previous hash command invocations. The display may also contain those commands invoked and found through the normal command search process.

Note: Shell built-in commands are not reported by the hash command.

You can use the -r flag to clear the contents of the command path name list. Path names can also be cleared from the list by resetting the value of the PATH environment variable. In the simplest form, this would be achieved by entering:


If the Command parameter is used, the hash command searches for the path name of the specified command and adds this path to the list. Do not use a / (slash) when you specify the command.

Since the hash command affects the current shell environment, it is provided as a Korn shell or POSIX shell regular built-in command. If the hash command is called in a separate command execution environment, as in the following examples, it will not affect the command search process of the caller's environment:

nohup hash -r
find . -type f | xargs hash

Using the hash command is equivalent to using the alias -t command.


-r Clears the contents of the path name list.


Command Specifies the Command to add to the path name list.

Exit Status

The following exit values are returned:

0 Successful completion.
>0 An error occurred.


  1. To find the path name of the wc command and add it to the path name list, enter:
    hash wc
  2. To clear the contents of the path name list, enter:
    hash -r


/usr/bin/ksh Contains the Korn shell hash built-in command.
/usr/bin/hash Contains the hash command.

Related Information

The alias command, bsh command, ksh command.

[ Previous | Next | Contents | Glossary | Home | Search ]