What does "wget -O" mean?

Sean Nguyen picture Sean Nguyen · Mar 22, 2012 · Viewed 60.7k times · Source

I have an wget command like this in my shell script:

reponse="`wget -O- http:localhost:8080/app/index.html`"

I don't understand the -O- option. I was explained that -O is output to somewhere and - is output to the current stream. I don't see any explaination of "-" in wget. Is that a standard thing for shell scripting. Where I can find reference to it?

Thanks,

Answer

Mingyu picture Mingyu · May 27, 2013

Here's the man page of wget -O:

http://www.gnu.org/software/wget/manual/html_node/Download-Options.html#Download-Options

Here's a few examples:

  1. wget with no flag

    wget www.stackoverflow.com
    

    Output:

    A file named as index.html

  2. wget with -O flag

    wget -O filename.html www.stackoverflow.com
    

    Output:

    A file named as filename.html

  3. wget with -O- flag

    wget -O- www.stackoverflow.com
    

    Output:

    Output to stdout