Alexandr Malusek wrote:
Jon Pennington
writes: Later on, I'll add the necessary header information, but for now, I need to strip the extra RPM version data from the file. It has a list of RPMs like this:
WindowMaker-0.64.0-63 a2ps-4.13-74 aaa_base-2001.5.22-0
But I need a list like this:
WindowMaker a2ps aaa_base
So I need a quick and dirty way to strip every line of every "-[0,9]*" and keep the rest of the name intact. It's a bit tricker since some packages don't use underscores but hyphens to seperate parts of the package name, such as alsa-devel, which means you can't just strip everything past the first hypen. Whaddayathink?
Basically, you can do it like this:
#!/bin/bash
rpm -qa | sort | while read name_ver_rev; do name_ver=${name_ver_rev%-*} name=${name_ver%-*} echo $name done
But I don't understand why you just don't print the names:
$ rpm -qa --queryformat "%{NAME}\n" | sort
That`s good. I had this problem a longer time ago, too and I did the following rpm -qa | cut -d"-" -f1 | sort But I did not know rpm has an option for this. So I learned now.... Rene