[TriLUG] Printing all RPMs by group

rpjday rpjday at mindspring.com
Tue Jan 1 13:42:53 EST 2002


On Tue, 1 Jan 2002, Tom Bryan wrote:

> During an upgrade to Red Hat 7.2, I find that I have run out of space on 
> /usr/ to install some of the packages that I want.  In an attempt to start 
> cleaning up my system (to get a higher ratio of used/unused programs on my 
> system), I wanted to print all of the RPMs on my system, grouped by RPM 
> group.  For those interested, here's what I did:
> 
> for x in `cat /usr/share/doc/rpm-4.0.3/GROUPS`
> do  
> 	echo $x 
> 	rpm -q -g $x
> 	printf "\n" 
> done > rpms.txt
> 
> enscript --landscape --columns=4 --truncate-lines --output=rpms.ps rpms.txt
> 
> lpr rpms.ps
> 
> So, I have two reasons for sending this message.  I thought that I'd start 
> your New Year with a handy script, and I wanted to ask if there is a more 
> standard way of doing this.

you might want to extend this by, for each group, checking if there
are *any* RPMs in that group and, if not, don't print anything for
that group at all:

#!/bin/bash

while read group ; do
	if rpms=$(rpm -q -g $group) ; then
		echo $group
		echo $rpms
	fi
done < /usr/share/doc/rpm-4.0.3/GROUPS > rpms.txt

... customize to taste ...

rday




More information about the TriLUG mailing list