Remembers or reports command path names.
hash [ Command ... ]
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.|
The following exit values are returned:
|>0||An error occurred.|
|/usr/bin/ksh||Contains the Korn shell hash built-in command.|
|/usr/bin/hash||Contains the hash command.|
The alias command, bsh command, ksh command.