Got the script mainly with google search on the <a href="http://linux.derkeiler.com/Mailing-Lists/Fedora/2006-12/msg04156.html">link.
Nice trick..
Get the list of rpms with just the names
rpm -qa –queryformat ’%{name}\n’ > pkglist
Get the non-uniques list.
sort -g pkglist | uniq -d > duplicates
Get the versions of the duplicate files:
for pkg in `cat duplicates`; do
rpm -q $pkg » removelist
done
Now keep the rpms that you want to delete in the removelist
Continue reading