Have you ever wanted to create a list of the installed RPMs in a format that you can re-use?
The RPM command below gets piped to sed to strip off the version information.
rpm -qa |sed ‘s/-[0-9].*//g’ |sed ‘s/.*$/\L&/g’ | sort
The resulting output looks like this:
acl
acpid
aide
alsa-lib
alsa-lib
alsa-lib-devel
alsa-utils
amtu
anacron
antlr
apr
…
The standard rpm -qa output looks like this:
cvs-1.11.22-7.el5
atk-devel-1.12.2-1.fc6
libXp-1.0.0-8.1.el5
libbonobo-devel-2.16.0-1.1.el5_5.1
libXres-1.0.1-3.1
libXcursor-devel-1.1.7-1.1
diffstat-1.41-1.2.3.el5
libIDL-devel-0.8.7-1.fc6
This isn’t very useful for installing packages on another server.
If you use rpm -qa |sed ‘s/-[0-9].*//g’ |sed ‘s/.*$/\L&/g’ | sort > /path/to/my/rpm/file you can then read the files from the file and then install the same packages on another server.
An example is:
for rpm in $(cat /path/to/my/rpm/file); do yum -y install $rpm;done
This will install all rpms (as needed) listed in /path/to/my/rpm/file and will not prompt (the -y flag) you.