We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

wget: save as specific file

hankknight
hankknight asked
on
Medium Priority
614 Views
Last Modified: 2012-05-11
I want to download a webpage and save it as "/my/dir/hello.html"

If the file already exists, I want it to be overwritten.  This does NOT work:
wget http://example.com/page.html >hello.html

Open in new window

Comment
Watch Question

CERTIFIED EXPERT

Commented:
Try

wget -r http://example.com/page.html


If you want to set your destination directory, use -P option.

Author

Commented:
Neither of those ideas work for me.

  -o  does NOT output the file contents
  -P  lets me set the directory but not change the file name.

I want to download a webpage and save it as "/my/dir/hello.html"
CERTIFIED EXPERT

Commented:
It is upper case O not o

So you need


wget -O http://example.com/page.html > /my/dir/hello.html

Open in new window

Author

Commented:
That gives me an error:
wget: missing URL Usage: wget [OPTION]... [URL]... Try `wget --help' for more options.
CERTIFIED EXPERT

Commented:
Well, I tried and it worked for me.  I tried this

 wget -O http://www.cic.gc.ca/english/pdf/kits/forms/imm0008egen.pdf > imm.pdf

I did not have a good example but it works for me.

Can you show an example for WWW that doesn't work.
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks.  Here is the code that I got working for me:
wget --output-document /my/dir/page.html http://example.com/ -o /dev/null

Open in new window

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.