I'm not sure I understand your question. If I *do* understand it you want to find out if a utility exists somewhere in the path then you want to use the which command.
Using that in a script...
Code:
if ! which python &> /dev/null;then
echo "Python is not installed."
else
echo "$(python --version) is installed."
fi
However, that won't detect if you have multiple versions of python installed. It will only detect if you have at least one binary called python installed somewhere in the $PATH. If you want to know about all possible instances of python installed in the $PATH you should do the following...
Code:
if ! which python &> /dev/null;then
echo "Python is not installed."
else
echo "$PATH" | tr ':' '\n' | sort -u | while read x;do
[ -f "$x/python" ] && ( echo -n "$x/python - ";$x/python --version )
done
echo "Default: $(which python) - $(python --version)"
fi
That last snippet of code will test if python is installed... if it is it will iterate through all of the paths in the $PATH variable looking for an executable file called python. Then it lists the path of each version and the version of python it is. At the end it shows the default python instance if the user simply types python on the shell. I just arbitrarily chose the python executable but you can wrap that in a function and choose any executable to find all versions of it.
Hopefully, I understood your question.