Previous | Table of Contents | Next |
DESCRIPTION
The aliased hash command forces a tracked alias for a specific command. It is an alias for the alias -t command. A tracked alias is the full pathname for a command. This reduces the time it takes the shell to search for the command and execute it. Since the full path is known to the shell through the alias name , the shell does not have to search each directory listed in the PATH variable, thus reducing the time it takes to invoke a command.
COMMAND FORMAT
Following is the general format of the hash command.
hash command
Arguments
The following argument may be passed to the hash command.
command | The name of the command you wish to have tracked. For example, | |
hash ls | ||
forces the ls command to be a tracked alias. | ||
If no argument is provided, then all tracked aliases are displayed. |
Automatic hashing
You can use the set command to have all commands you enter on the command line become tracked aliases. The command
set -o trackall
or
set -h
causes automatically tracked aliasing.
RELATED COMMANDS
Refer to the alias command described in Module 4.
APPLICATIONS
The hash command is used to create tracked aliases for commands. Tracked aliases provide the shell with the entire pathname for a command. This allows the shell to locate the command faster and thus less overhead is needed to execute a command.
TYPICAL OPERATION
In this activity you use the hash command to create a tracked alias for the vi command and then display all tracked aliases. If you re using the csh, skip to the next module. Begin at the shell prompt.
cj> hash vi=/usr/bin/vi
Previous | Table of Contents | Next |