Remove version numbers from package lists

I just upgraded my laptop from Fedora 13 to 14, and normally, before I do the upgrade (Fresh install) I run an rpm command to make a list of all the packages I have installed, but without the version and architectures specified, so that I can just feed that list to yum after the upgrade to reinstall all the packages I had installed "post-install" after my last installation. However, stupid me I forgot to do that this time, I just did a regular "rpm -qa | sort" command, so I have a package list like this:

Rather than like this:

I like using the shell, however I am by no means a shell ninja, so I would like to ask, are there any shell ninjas out there, who can think of a command or shell script to strip away version numbers and architectures away from the package list that I got, so that it is merely the package name itself left, as illustrated above.

Thanks a lot in advance! :slight_smile:

 
rpm -qa | sort | sed -e 's/\([^.]*\).*/\1/' -e 's/\(.*\)-.*/\1/'
1 Like

Fantastic! Thanks a lot, you just saved me a lot of time and headache, I really appreciate it!