I need to check if mysql is installed from within a bash script. What would be an efficient way of doing that? I thought I could do this:
if [ ! -f `which mysql` ] ; then
echo "foo"
fi
But I think I might be confused about something. What would be a better solution? It should be portable and work on both Ubuntu
and OSX
.
which
only returns regular files anyway. This test will always be false.which mysql
to give back the path to mysql that then is checked if it's a file or not. But it seems to just not work.[
is an external command, as ifwhich
does not return anything,-f
will be missing an argument.