I'm trying to write a script to detect if it's being run on RHEL/RPM based distros.I've faced some odd systems configured such that both dpkg and rpm are installed, so doing a which rpm isn't a solution.I attempted this:if [[ $(cat /etc/*[_-][rv]e[lr]*) == (CentOS|Fedora) ]]; then  #...fibut this requires me to know the names of all distributions that are based on RHEL/RPM.
Detecting RHEL/RPM based distros
rhel;rpm
If your purpose is to detect whether rpm is the package manager on that system, a good heuristic should be that the RPM package database is not empty.if [ -n $(rpm -qa) ] 2>/dev/null; then  echo This looks like an rpm-based systemelse  echo Either there is no rpm command, or the rpm package database has no entriesfi