Removing duplicate RPMS.

2010-05-12 1 min read Linux

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 &#8217;%{name}\n&#8217; > 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

and a simple command to remove them will be :
for pkg in `cat removelist`; do
rpm -e $pkg
done

comments powered by Disqus