5

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
3
  • why rpm -ivh filename won't do it? Jan 18, 2012 at 22:07
  • @HubertKario, yum will resolve dependencies.
    – cjc
    Jan 18, 2012 at 22:25
  • @HubertKario Also, AFAIK, that installed filename as if it is an RPM package, but here filename is a list of package names that need to be fetched.
    – alecbz
    Aug 31, 2017 at 13:39

3 Answers 3

13
xargs yum -y install < filename
6

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.

4
  • 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, 2012 at 17:33
  • @cyberx86 - I did the tr bit out of paranoia :)
    – warren
    Jan 18, 2012 at 17:34
  • The accepted practice nowadays is to wrap Bash shell commands with $( foo bar) instead of backticks.
    – Magellan
    Jan 18, 2012 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, 2012 at 22:04
0

This works:

yum localinstall /path/to/file.rpm

You must log in to answer this question.

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