I've written this function:
function isInstalled {
if [ rpm -q $1 &> /dev/null ]; then
echo 'installed';
return 1;
else
echo 'not installed';
return 0;
fi
}
But something is wrong. It always returns 0. Even when package is installed. I guess I'm not checking the return signal correctly.
[vagrant@centos-7 ~]$ isInstalled wget2
not installed
[vagrant@centos-7 ~]$ isInstalled wget
not installed
[vagrant@centos-7 ~]$ rpm -q wget
wget-1.14-10.el7_0.1.x86_64