Hash (Unix)
Standard UNIX utility
hash is a command on Unix and Unix-like operating systems that prints the location information for the commands found. The hash command has also been ported to the IBM i operating system.
01Description
When the user gives a command, the shell searches for the command in a list of locations specified by the PATH environmental variable. To avoid this work in future, when a command is found its location is stored in a hash table which is consulted before the search. The hash command is used to display or manipulate that hash table, particularly to replace obsolete entries in the rare but possible case that a command is added to the PATH. The hash command is built into the shell. The C shell implements this command in a different way.
02Options
The following options are supported.
- name
- Searches the PATH environmental variable for the name given
03Exit Status
This command returns the following exit values:
- 0
- Successful completion
- 1
- An Error occurred
04Examples
Print the hash table.
$ hash catSearches for command cat in the path specified by PATH environmental variable; if found, adds it to the hash.
Sources and credits
This article is adapted from the Wikipedia article “Hash (Unix)”, written by its contributors and licensed under CC BY-SA 4.0. Fathomly has changed the layout, removed citation markers, navigation and maintenance notices, and adjusted punctuation. This adapted version is shared under the same license. For references, see the original article.
Fathomly is not affiliated with or endorsed by the Wikimedia Foundation. Spotted a problem? Tell us.