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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s