I found a great answer on here already (Test if a command outputs an empty string)
I'm trying to apply this to the rpm -e --test command. I want to be able to check for dependencies prior to placing a package in a list for removal. So my simple script looks like this thus far:
for PKG in pkg1 pkg2
do
if [[ $(rpm -e --test $PKG) ]]; then
echo "there are dependencies for $PKG"
else
echo "remove $PKG"
fi
done
However no matter if a package has a dependency or not I always fall through to the else case. Any thoughts on how to go about this differently?