Comparing RPM’s between servers

Periodically, I will want to compare the RPM installations between two or more servers. Sometimes, I may not care about the specific versions of each RPM, but only that *some* version exists. To do this, I can use awk and print only the name of the RPM up to but not including where the version number begins.

First, we show the versions with a normal rpm -qa command…

CMHLDEVPSOFT01:oracle:fn9dev:/home/oracle>rpm -qa | head -10
tzdata-2011g-1.el5
expat-1.95.8-8.3.el5_5.3
libusb-0.1.12-5.1
gdbm-1.8.0-26.2.1
procps-3.2.7-17.el5
libIDL-0.8.7-1.fc6
libksba-1.0.5-2.el5
libtevent-0.9.8-10.el5
less-436-7.el5
eject-2.1.5-4.2.el5
CMHLDEVPSOFT01:oracle:fn9dev:/home/oracle>

…and then show how we can strip the version information from the RPM name…

CMHLDEVPSOFT01:oracle:fn9dev:/home/oracle>rpm -qa | awk -F "-" '{i=1;while (i <= NF) {if ($i !~ /'^[0-9]'/) {if(i==1) {s=$i} else{s=s"-"$i};i++}else{print s;s="";next}}}' | head -10
tzdata
expat
libusb
gdbm
procps
libIDL
libksba
libtevent
less
eject

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.