I've done rpm -qa > file and now I want to copy the file to another server and run through it and install all these packages on the new server. I did something like this: for pkg incat file; do yum -y install $pkg; done and it works but takes too much time, do you know a shorter way to achieve this goal? I do not have an automatic configuration manager software installed. If I knew how to run through the file and switch the newline with just a space I could run it simply by: yum install -y pkg1 pkg2 pkg3 but I don't know how to manipulate the data on the file so it will be displayed like that. (having spaces instead of newlines)

3 Answers 3


No need; xargs doesn't care which whitespace you use.

xargs yum -y install < file
rpm -qa > file 

contains version numbers. Its best to ignore it, in case the destination server has different architecture or the package has updated version. Retrieve the package name only with the following command:

$ rpm -qa --queryformat "%{NAME}\n"

No need to use xargs at all.

rpm -qa > file

yum -y install $(cat file)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .