Bash 'type someCmd' : what means 'hashed'? (different outputs for 'type mkdir')
The difference is situational:
The first time bash
executes an external utility in a given session by filename only (whether successfully or not), it remembers its full path for faster re-execution later (saving the need to look for the utility in all directories listed in the $PATH
variable again).
This remembering (caching) is called hashing and happens implicitly via builtin hash
.
Therefore, before mkdir
is ever executed in a given session, type mkdir
returns:
mkdir is /bin/mkdir
After having executed mkdir
at least once, type mkdir
then reports:
mkdir is hashed (/bin/mkdir)
You can tell bash
to "forget" all remembered paths with hash -r
, or selectively with hash -d <name>
; just hash
prints all currently hashed paths and their hit counts - see help hash
.