Module 62 hash (ksh)

Previous Table of Contents Next


Module 62
hash (ksh)

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.

1.    Type hash vi and press Return . This creates a tracked alias for vi .
2.    Type hash and press Return to display all tracked aliases.
 cj> hash      vi=/usr/bin/vi 
3.     Turn to Module 68 (SV), Module 9 (BSD) to continue the learning sequence.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net