I need to check for installed packages and if not installed install them.
Example for RHEL, CentOS, Fedora:
rpm -qa | grep glibc-static glibc-static-2.1
Based on @GillesQuenot and @Kidbulra answers, here's an example how to loop over multiple packages, and install if missing:
packageList="git gcc python-devel" for packageName in $packageList; do rpm --quiet --query $packageName || sudo yum install -y $packageName done