Is there any way to install packages through yum from a file?

Something like:

yum -f packages.txt

I couldn't find anything in the man pages.

packages.txt would contain something like:

bash
bc
binutils
bzip2
bzip2-libs
ca-certificates
cairo
link|improve this question

75% accept rate
why rpm -ivh filename won't do it? – Hubert Kario Jan 18 at 22:07
@HubertKario, yum will resolve dependencies. – cjc Jan 18 at 22:25
feedback

2 Answers

up vote 6 down vote accepted
xargs yum -y install < filename
link|improve this answer
feedback

This works:

yum install `cat <filename> | tr '\n' ' '`

As should:

yum install `cat <filename>`

I added the pipe to tr as a sanity check, just in case the environment is wacky.

per a comment:

yum install $(cat <filename>)

will also work, rather than using the backticks.

link|improve this answer
Just tried the exact same thing - interestingly enough, it doesn't seem necessary to remove the line breaks (although, of course, it works with them removed) – cyberx86 Jan 18 at 17:33
@cyberx86 - I did the tr bit out of paranoia :) – warren Jan 18 at 17:34
The accepted practice nowadays is to wrap Bash shell commands with $( foo bar) instead of backticks. – Adrian Jan 18 at 20:43
@AdrianK - thanks for the suggestion. I've been using backticks for a really long time ... it'll take some getting used to :) – warren Jan 18 at 22:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.