61

This question explains how to do it with curl. The accepted answer also points out that

If wget is available, that would be far simpler.

I looked through man wget but the got lost in there, and didn't find an option to follow redirects.

1
  • 1
    you mean man wget?
    – dovah
    Aug 23, 2016 at 15:20

3 Answers 3

56

wget follows redirects automatically. Just give the URL as an argument

wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz'
7
  • 1
    Oh. I had given it the wrong url and wandering why it is not working. Thanks a lot.
    – Vorac
    Aug 16, 2013 at 8:18
  • 4
    Sourceforge URL's often need to be quoted due to the &'s in them as well (pre redirect)
    – Matt
    Aug 16, 2013 at 15:46
  • 2
    Note that when using wget with the SourceForge download URL, the wget output shows the Location: header containing the "real" URL to which the HTTP GET operation is redirected. Copy this URL for subsequent use with HTTP GET agents that cannot follow redirects. Dec 28, 2015 at 16:38
  • 1
    this does not work anymore: executing your command ends up with a download?use_mirror=vorboss.html file. What is the solution now? Nov 1, 2016 at 10:20
  • 1
    You have a %22 (") at the end of the URL. I had no problems with wget 'http://downloads.sourceforge.net/project/romfs/genromfs/0.5.2/genromfs-0.5.2.tar.gz'
    – Matteo
    Feb 15, 2017 at 10:05
9

Start the download in chrome browser. When it starts cancel it and go to downloads page. You can see the url for the download. Copy it and use it with wget.

5
  • 2
    This seems to be unnecessarily complicated.  Note that some systems don't have Chrome installed.  Is there any reason why your answer would be preferable over the two-year-old one? Jun 2, 2015 at 8:27
  • 1
    Aptly said about chrome. I was just trying to provide a simple trick that might be useful for other sites as well. Jun 2, 2015 at 8:53
  • 3
    Works in Firefox as well. Feb 14, 2018 at 4:58
  • 1
    Why "chrome browser"? BTW, this is not convenient for using in a command line environment. Normally, people who use wget are not in a graphical environment.
    – cedbeu
    Oct 6, 2018 at 22:03
  • Thanks for sharing this trick - I was struggling with getting the actual download URL to used when downloading programmatically.
    – Raven
    Oct 1, 2020 at 15:52
6

Click the link, you'll get redirected, and you'll see something like "Redirecting... if you are not automatically redirected, click the direct link.

Copy that [direct] link's location, paste it in the command-line like this

wget "http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz"

That's it! It worked for me.

Edit: You should omit everything after the '?' character in the url, or else the filename will also have this part.

3
  • 1
    Doesn't wget automatically follow redirects for you? Nov 17, 2015 at 15:11
  • 1
    @DmitryGrigoryev it would, if it were a proper 301/302 redirect. This is a landing page followed by a scripted redirect.
    – muru
    Nov 17, 2015 at 15:17
  • 1
    Thanks, your post solved my annoying problem. In current sourceforge download page, "direct link" is show if you click the "Problems Downloading?" button.
    – user802708
    Nov 27, 2018 at 3:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .