Remove version numbers from package names

/bin/rpm -qa | sed 's/-[0-9].*//'

is wrong.

Use this instead:

/bin/rpm -qa --qf "%{n}\n"

Mad props to ssatoh and rhonda.

That is all.

Comments

  1. Anonymous3/5/11 20:58

    different solution: rpm -qa --qf "%{n}\n"

    ReplyDelete
  2. Anonymous4/5/11 16:58

    Actually, that's not a different solution, it's the PROPER solution. The original poster's snippet would happily remove any part of the package name that happens to start with -[0-9].

    Packages that are affected on the system I'm on are compat-libstdc++-33, xorg-x11-fonts-ISO8859-1-75dpi, java-1.4.2-gcj-compat.

    There is even an error in the other direction: The version of cdparanoia-libs-alpha9.8 isn't stripped because it doesn't start off with a digit.

    (for the curious, this is on Red Hat Enterprise Linux Server 5.6)

    ReplyDelete
  3. Wow, thanks. Learned something new again. Updating the post.

    ReplyDelete

Post a Comment

Popular posts from this blog

Pull files off Android phone