28

I was wondering whether using wget it was possible to download an RPM and then pipe it through sudo rpm -i to install it, in a single line? I realize I could just run:

wget -c <URL>
sudo rpm -i <PACKAGE-NAME>.rpm

to install the package but I was wondering whether it might be possible to do this in a single line using the quiet and write to standard output options of wget. I have tried using:

wget -cqO- <URL> | sudo rpm -i

but it returned:

rpm: no packages given for install
3
  • Did you try sudo rpm -i <URL>?
    – Mikel
    Nov 27, 2015 at 15:05
  • Have you tried wget -cqO- <URL> | xargs sudo rpm -i or maybe sudo rpm -i $(wget -cqO- <URL>)? What error do they give?
    – Firelord
    Nov 27, 2015 at 15:54
  • 1
    @Firelord. 1st command: just gave it a try and it gave the error shown here. 2nd command: gave the error rpm: no packages given for install.
    – Josh Pinto
    Nov 27, 2015 at 16:02

3 Answers 3

39

RPM has native support to download a package from a URL. You can do:

sudo rpm -i <URL>

There is no need to download the RPM manually. If this support didn't exist, you could use bash's process substitution.

sudo bash -c 'rpm -i <(wget -O - <URL>)'
2
  • 9
    It's better to use yum install -y <URL>, because it will also install any dependencies.
    – cristi
    Nov 27, 2015 at 15:36
  • 2
    Well if I were using a distro that uses yum as its package manager it would, but remember RPM packages are also used by distros that use APT-RPM, DNF, urpmi and ZYpp package managers. Turns out I was using openSUSE Tumbleweed, which uses ZYpp.
    – Josh Pinto
    Nov 27, 2015 at 15:55
21

Better to do yum install -y <URL> as this does alto take care of dependencies, as opposed to direct rpm tool use.

2
  • As I said in the comments on jordanm's answer I was using openSUSE Tumbleweed, yum isn't available on Tumbleweed.
    – Josh Pinto
    Nov 17, 2017 at 5:35
  • 1
    Lol @sorin yum is not available wtf.
    – avia
    May 15, 2021 at 22:41
2

I guess one possible way could be to define the filename of what you are downloading:

wget -cqO- <URL> -O my-output-file.rpm && sudo rpm -i my-output-file.rpm

But surely there must be better approaches

2
  • I won't accept this answer as (as you said) I'm hoping for better approaches but, you know this is a good attempt, so thanks.
    – Josh Pinto
    Nov 27, 2015 at 15:04
  • @JoshPinto this is not a good approach, it is the only correct answer..
    – avia
    May 15, 2021 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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