Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "wget -O" mean?

Tags:

wget

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,

like image 233
Sean Nguyen Avatar asked Mar 22 '12 20:03

Sean Nguyen


People also ask

What does wget O do?

This command downloads the csv file from the specified url and saves it as teleComData. csv . If you hadn't used the -O flag, it would simply save the file as it is.

What is wget P?

Wget is a free command-line utility and network file downloader, which comes with many features that make file downloads easy, including: Download large files or mirror complete web or FTP sites. Download multiple files at once. Set bandwidth and speed limit for downloads. Download files through proxies.

What is a wget file?

Wget is a networking command-line tool that lets you download files and interact with REST APIs. It supports the HTTP , HTTPS , FTP , and FTPS internet protocols. Wget can deal with unstable and slow network connections. In the event of a download failure, Wget keeps trying until the entire file has been retrieved.

Do I need wget?

Wget is primarily used when you want a quick, cheap, scriptable/command-line way of downloading files. So, for example, you can put wget in a script to download a web page that gets updated with new data frequently, which is something a browser can't really be used for.


2 Answers

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

like image 110
Mingyu Avatar answered Oct 03 '22 01:10

Mingyu


for the manual of wget: use man wget if you are on Unix platform. Else, try "man page wget" on google.

The -O- stand for "Get as a file and print the result on STDOUT"

like image 45
Vodun Avatar answered Oct 03 '22 01:10

Vodun