I am trying to find out if certain RPM packages exists in an array. if any of the package is missing it will exit with the message "Package doesnt exist" .Here is my code
#!/bin/bash
echo "Checking for Pre-requisites X11 libraries required for installation"
my_array=(xorg-x11-drivers xorg-x11-utils xorg-x11-xauth xorg-x11-xinit initial-setup-gui initial-
setup-gui install initial-setup-gui glx-utils )
for (( i = 0; i < ${#my_array[@]} ; i++ )); do
#printf "\n**** checking: ${my_array[$i]} *****\n\n"
if rpm ! -qa "${my_array[$i]}"
then
echo "Package missing"
exit 1
else
echo "All Package available"
exit
fi
done
But this one seems to do the opposite that is exiting on finding a matching package. Can someone pls let me know how i am messing up here ?