An Open Access Peon

23 February 2007

Removing Duplicate RPM Packages

To find a list of packages that have a newer version installed use:


rpm --last -qa | perl -n -e '/^(\S+)-\S+-\S+/; print "$&\n" if $SEEN{$1}; $SEEN{$1} ||= $_;' | sort | uniq >dupes.txt


The --last argument causes RPM to list packages by install date (newest first). We remove any packages with the same name as a more recently installed package.

To actually remove the packages (as root):


for i in $(cat dupes.txt); do rpm -e $i && echo $i; done


Depending on dependencies you may need to run this more than once.