Created
May 4, 2012 10:31
-
-
Save mlafeldt/2593960 to your computer and use it in GitHub Desktop.
[Shell] Command hashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # empty hash table | |
| echo "-- hash table --" | |
| hash | |
| # hash location of commands | |
| ifconfig >/dev/null | |
| which ls >/dev/null | |
| echo "-- hash table --" | |
| hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ dash ./hash.sh | |
| -- hash table -- | |
| -- hash table -- | |
| /sbin/ifconfig | |
| /usr/bin/which | |
| $ bash ./hash.sh | |
| -- hash table -- | |
| hash: hash table empty | |
| -- hash table -- | |
| hits command | |
| 1 /usr/bin/which | |
| 1 /sbin/ifconfig | |
| $ zsh ./hash.sh | |
| -- hash table -- | |
| -- hash table -- | |
| ifconfig=/sbin/ifconfig | |
| ls=/bin/ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment