Name
hash
Synopsis
hash [-dlrt] [-pfile] [commands]
As the shell finds commands along the search path ($PATH), it remembers the found location in an internal hash table. The next time you enter a command, the shell uses the value stored in its hash table.
With no arguments, hash lists the current hashed commands. The display shows hits (the number of times the command has been called by the shell) and the command name.
With commands, the shell adds those commands to the hash table.
Options
-dRemove (delete) just the specified commands from the hash table.
-lProduce output in a format that can be reread to rebuild the hash table.
-pfileAssociate file with command in the hash table.
-rRemove all commands from the hash table.
-tWith one name, print the full pathname of the command. With more than one name, print the name and the full path, in two columns.
Besides the -r option, the hash table is
also cleared when PATH is assigned. Use PATH=$PATH to clear the hash table
without affecting your search path. This is most useful if you
have installed a new version of a command in a directory that is
earlier in $PATH than the current version of the command.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access