Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to download a file from sourceforge using wget, but as we all know we have to click on the download button and then wait for it to auto download. how do you download this type of file using wget?

I am trying to download this: http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.1/bitcoin-0.8.1-linux.tar.gz/download

But doing a wget on that url link would not get me the file as the file is auto loaded via the browser.

share|improve this question
Going to that page in the web browser should also list a Direct Link - can you use wget with that? – BriGuy May 1 '13 at 18:58
up vote 2 down vote accepted

I'm unsure which version of wget or OS and any proxy's exist between you and sourceforge but wget downloaded the file when I removed the "/download" and left it at the file extension.

I don't want to flood the post or pastebin my entire session but I got the 302 then 200 status codes before the transfer began. What happens when you try wget?

Resolving downloads.sourceforge.net...
Connecting to downloads.sourceforge.net||:80... connected.
HTTP request sent, awaiting response... 302 Found

[snipped for brevity]

HTTP request sent, awaiting response... 200 OK
Length: 13432789 (13M) [application/x-gzip]
Saving to: `download'
share|improve this answer

I would suggest using curl to do this instead of wget. It can follow the redirection using the switches -L, -J, and -O.

curl -O -J -L http://sourceforge.net/projects/bitcoin/files/Bitcoin/bitcoin-0.8.1/bitcoin-0.8.1-linux.tar.gz/download

switch definitions

  Write output to a local file named like the remote file we get. 
  (Only the file part of the remote  file  is  used, the path is cut off.)

  (HTTP/HTTPS)  If  the  server  reports that the requested page has moved 
  to a different location (indicated with a Location: header and a 3XX 
  response code), this option will make curl redo the request on the new 
  place.  If  used together  with  -i/--include  or -I/--head, headers from 
  all requested pages will be shown. When authentication is used, curl only 
  sends its credentials to the initial host. If a redirect takes curl to a 
  different host, it  won't be  able  to  intercept  the  user+password. 
  See also --location-trusted on how to change this. You can limit the
  amount of redirects to follow by using the --max-redirs option.

  (HTTP) This option tells the -O/--remote-name option to  use  the  
  server-specified  Content-Disposition  filename instead of extracting a 
  filename from the URL.

See the curl man page for more details.

share|improve this answer
No need to use curl, wget can follow redirects, but it doesn't do so unless you increase the --max-redirect from the default, which for security reasons is of course 0. – Anthon Mar 1 '15 at 13:57

In wget you may use --content-disposition option which is useful for some file-downloading CGI programs that use "Content-Disposition" headers to describe what the name of a downloaded file should be.

In example:

wget --user-agent=Mozilla --content-disposition -E -c http://example.com/

For more complex solutions (like authorisation required), use cookie file (--load-cookies file) to simulate your session.

share|improve this answer

Your Answer


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.