Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm getting familiar with the terminal commands, and I came across this command to install the Heroku toolbelt:

wget -qO- https://toolbelt.heroku.com/install.sh | sh

Now from here I gather that wget is used to download files from the internet through various supported protocols, and they'll download even if I logoff.

Is that right?

And I wanted to know two more things about that command :

  1. I see -q0- in the code. What does it mean? From manpages I see that -q is used to turn the output of Wget off. But what does that mean too? And how is using -q different from -q0-

  2. What is the |sh at the end of the command for? What does that do?

Thank you very much for the time!

share|improve this question
2  
I see you have several helpful answers. I would just add that you shouldn't execute that command unless you are confident you can trust the website--since you will be directly executing whatever it downloads without a chance for you to look at it. It may be worthwhile to execute wget toolbelt.heroku.com/install.sh which will put the file in your current directory. Then you can examine it. (I'm not making a comment about heroku or that website, it's just a general comment). –  John S Gruber Jul 26 '12 at 22:39
add comment

3 Answers 3

up vote 4 down vote accepted

That command actually is wget -qO not wget -q0.

It will download the file https://toolbelt.heroku.com/install.sh silently (-q option) and anything downloaded will be will be concatenated together and written to a single file buffer file (-O option), that downloaded buffer will then be pipped to and executed with sh.

sh is a shell interpreter that will run the information that wget just downloaded.

So, in simple words you are telling with this command: download this sh file and don't create a progress output and whatever you download execute it with sh.

share|improve this answer
add comment
  1. Like most isolated programs started from a terminal, wget normally will NOT continue running after its parent (terminal) has been closed (via logout, etc. )

  2. -qO- is an abbreviation of the two command line options -q -O-

    • q tells wget not to output status/progress info
    • O- tells it to output the downloaded data to standard output
  3. | sh pipes the data from standard output to the sh command, executing the script

share|improve this answer
    
Thank you for explaining that -qO- is an abbreviation of two separate commands. I knew what -q did, and what -O did, but didn't realize they could be combined in that way. –  Ted M. Young Mar 21 at 21:41
add comment

That is not a 0 (number) it's an O (letter), it redirects the output to a file, in this case (-) the standard output, so the downloaded file's content will be redirected (by the |) to the sh standard input. sh is a shell, a command interpreter that will execute the commands it receives.

You can learn more searching for Redirections in sh manpage (man sh).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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