Bash hash builtin command
On Unix-like operating systems, hash is a built-in command of the bash shell that views, resets, or manually changes the bash path hash. The path hash is a hash table, maintained by bash, that contains the locations on disk where the shell should look for executable programs when a command is run.
When you run a command, bash looks up its location on disk in the hash table. This table of locations was previously determined when the shell was launched, according to the PATH environment variable in the shell's init script, e.g. .bashrc or .bash_profile.
The hash table is maintained automatically, but you can force it to re-calculate its program locations with the hash command.
hash [-l] [-r] [-p pathname] [-d] [-t] [commandname ... ]
Determine and remember the full pathname of each commandname. If no arguments are given, display information about remembered command locations.
|-d||Forget the remembered location of each commandname.|
|-l||Display information in a format that can be used as input for another program.|
|-p pathname||Use pathname as the full path of commandname.|
|-r||Forget all remembered locations.|
|-t||Print the remembered location of each commandname. If multiple commandnames are given, precede each location with corresponding commandname.|
|commandname||Each commandname specified is searched for in the PATH environment variable, and if found, is added to the list of remembered commands.|
The hash command returns 0 for success. Any other value indicates commandname not found, or invalid option given.
Display information about the hash table. If there is no pertinent information, this command displays nothing.
Forget all remembered locations, and determine them right now. If you run a command and bash can't find it (because you made a change to your system, for example), run hash -r and try the command again.
hash -d which
Forget the remembered location of the which executable (typically /usr/bin/which) and determine it right now.
hash -t which
Print the remembered location of the which command.