Download file with url redirection

BashUrlCurlDownloadWget

Bash Problem Overview


I can download a file by url but when I try it from bash I get a html page instead of a file.

How to download file with url redirection (301 Moved Permanently) using curl, wget or something else?

UPD

Headers from the url request.

> curl -I http://www.somesite.com/data/file/file.rar

HTTP/1.1 301 Moved Permanently
Date: Sat, 07 Dec 2013 10:15:28 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3
Location: http://www.somesite.com/files/html/archive.html
Vary: Accept-Encoding
Content-Type: text/html
X-Pad: avoid browser bug

Bash Solutions


Solution 1 - Bash

Use -L, --location to follow redirects:

$ curl -L http://httpbin.org/redirect/1

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionedemView Question on Stackoverflow
Solution 1 - BashdeltheilView Answer on Stackoverflow