O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

hash

Synopsis

hash [-dlrt] [-p file] [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 is called by the shell) and the command name.

With commands, the shell adds those commands to the hash table.

Options

-d

Remove (delete) just the specified commands from the hash table.

-l

Produce output in a format that can be reread to rebuild the hash table.

-p file

Associate file, assumed to be the full pathname, with command in the hash table rather than searching $PATH.

-r

Remove all commands from the hash table.

-t

With one name, print the full pathname of the command. With more than one name, print the command 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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required