Jon Pennington
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 -- Alexandr.Malusek@imv.liu.se
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
Rene Engelhard wrote:
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....
I forgot grep | after rpm -qa |, but it does not work for your interest because of alsa-devel..... I had not read properly.... :-( Rene
--- Alexandr Malusek
But I don't understand why you just don't print the names:
$ rpm -qa --queryformat "%{NAME}\n" | sort
This is perfect! I'll reboot shortly and re-get the package selection using this. I'd still like to see a decent way to strip a text file, but this will certainly do the task, thank you! ===== -- -=|JP|=- Hit me! - http://www.xanga.com/cowboydren/ Jon Pennington | Debian 2.3 -o) cowboydren @ yahoo . com | Auto Enthusiast /\\ Kansas City, MO, USA | ICQ UIN 69 67 29 31 _\_V __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com
Try this: cat /tmp/packagelist | while read fver ; do name=${fver%-[0-9\.]*-*} echo $name done > /tmp/namelist It'll work with packages like name-subname-N.N.N.N-xyz. ^ ^ | |--- release number |--------- version number Packages with weird version numbers will not be filtered right. Rafael
participants (4)
-
Alexandr Malusek
-
Jon Pennington
-
Rafael E. Herrera
-
Rene Engelhard