whereiz – find all version of a command

Using the following script it will find all version of a command in $PATH (from Unix Power Tools)

$ cat /tmp/whereiz
#!/bin/sh
testx=”test -x”

fixpath=”`echo $PATH | sed \
-e 's/^:/.:/' \
-e 's/::/:.:/g' \
-e 's/:$/:./'`”

# echo $fixpath
IFS=”: ”
for command
do
where=””
for direc in $fixpath
do $testx $direc/$command && where=”$where $direc/$command”
done
case “$where” in
?*) echo $where ;;
esac
done

Example
$ /tmp/whereiz ls grep
/bin/ls /tmp/ls
/bin/grep

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.