Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created May 4, 2012 10:31
Show Gist options
  • Select an option

  • Save mlafeldt/2593960 to your computer and use it in GitHub Desktop.

Select an option

Save mlafeldt/2593960 to your computer and use it in GitHub Desktop.
[Shell] Command hashing
#!/bin/sh
# empty hash table
echo "-- hash table --"
hash
# hash location of commands
ifconfig >/dev/null
which ls >/dev/null
echo "-- hash table --"
hash
$ 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