For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > RedHat > Strip RPM Versions

Strip RPM Versions

Created by dave. Last edited by dave, 4 years and 181 days ago. Viewed 2,865 times. #4
[diff] [history] [edit] [rdf]
labels
attachments

Problem

You want a list of RPMs installed on a system. You don't want the version number of the RPM, you just want a list of package names.

Solution

# rpm -qa | sed -e 's/-[^-]*-[^-]*$//' | sort | uniq > rpmlist.txt

The uniq is there to strip out multiple listings of the same RPM, if you have both the i386 and x86_64 versions installed, for example.

This works because all RPMs have at least two dashes in their names, the second-last of which is the beginning of the version. So you look for the second-last dash and strip off that and everything following it.

Easier

There's always an easier way, isn't there?

# rpm -qa --queryformat '%{NAME}\n'

If you care about architecture (ie for x86_64 systems which have some i386 RPMs installed):

# rpm -qa --queryformat '%{NAME}.%{ARCH}\n'

These can be specified exactly the same way in the kickstart file.

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt