Last active
August 29, 2015 14:14
-
-
Save ymyzk/5441e5512bbc63e6f0ff to your computer and use it in GitHub Desktop.
Comparison of 'which', 'command -v', 'type' and 'hash'
This file contains 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
query=vim | |
time bash -c "for i in {0..1000}; do which $query; done >/dev/null 2>&1" | |
time bash -c "for i in {0..1000}; do command -v $query; done >/dev/null 2>&1" | |
time bash -c "for i in {0..1000}; do type $query; done >/dev/null 2>&1" | |
time bash -c "for i in {0..1000}; do hash $query; done 2>/dev/null" | |
time zsh -c "for i in {0..100000}; do which $query; done >/dev/null 2>&1" | |
time zsh -c "for i in {0..100000}; do command -v $query; done >/dev/null 2>&1" | |
time zsh -c "for i in {0..100000}; do type $query; done >/dev/null 2>&1" | |
time zsh -c "for i in {0..100000}; do hash $query; done 2>/dev/null" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script