LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2014, 10:58 AM   #1
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
wget insists on saving a file


My bash script includes this:
Code:
echo; echo "#5"
wget http://releases.ubuntu.com/precise/MD5SUMS
I expected the contents of the referenced file to be displayed on the screen. That's not what happened. Instead, this is displayed:
Code:
#5
--2014-01-03 11:47:18--  http://releases.ubuntu.com/precise/MD5SUMS
Resolving releases.ubuntu.com... 91.189.92.163, 2001:7b8:3:37:213:136:29:219, 2001:67c:1360:8c01::14, ...
Connecting to releases.ubuntu.com|91.189.92.163|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 577 [text/plain]
Saving to: `MD5SUMS'

100%[======================================>] 577         --.-K/s   in 0s      

2014-01-03 11:47:19 (41.0 MB/s) - `MD5SUMS' saved [577/577]
Sure enough, the file /home/daniel/MD5SUMS was created and it contains the desired information.

Is there a command option which should have been used?

Daniel B. Martin
 
Old 01-03-2014, 11:12 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
From the manpage:

Code:
       -O file
       --output-document=file
           The documents will not be written to the appropriate files,
           but all will be concatenated together and written to file.
           If - is used as file, documents will be printed to standard
           output, disabling link conversion.  (Use ./- to print to a
           file literally named -.)

           ...
If you want to keep the screen clear, you may also need
Code:
       -o logfile
       --output-file=logfile
           Log all messages to logfile.  The messages are normally
           reported to standard error.
 
2 members found this post helpful.
Old 01-03-2014, 12:38 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Yes, wget is intended to get a file. I'm very glad the default operation doesn't dump the contents of the file you grabbed to the screen, that would make no sense for 99% of wget's use-cases, such as downloading files, which is what you are doing.

If you want to dump the contents of the file to the screen, then use "-O -". You can even put this straight into a variable with:
Code:
md5=$(wget -O - http://releases.ubuntu.com/precise/MD5SUMS)
 
2 members found this post helpful.
Old 01-03-2014, 02:29 PM   #4
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,881

Original Poster
Rep: Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660Reputation: 660
Thank you, ntubski and suicidaleggroll, for your prompt and informative responses.
This thread is marked SOLVED!

Daniel B. Martin
 
  


Reply

Tags
bash, wget



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wget: download if file size does not match any file in folder Si14 Linux - Software 1 04-21-2013 06:00 AM
Reading from binary file and saving elements to KML file in C dexter910 Programming 9 01-18-2012 11:06 AM
[SOLVED] How to change default file path when opening or saving a file bassplayer69 Slackware 4 11-18-2011 05:27 PM
How to use WGET from an URL for saving like "Save AS" from Firefox? Xeratul Linux - General 2 08-13-2011 05:47 AM
saving a page using wget+command -O not found+each time i'v to break manually Kakarot_Rathish Programming 5 04-13-2010 04:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration