The Finest Hand-Selected Downloads
Individually reviewed & tested
Store News

Automate all your downloads with curl

21 May 2014, Mike Williams

Curl is well known on Linux as a flexible command line tool which can download files using a wide range of protocols: HTTP, HTTPS, FTP, FTPS, POP3, IMAP, RTMP, RTSP and many more.

The program is also available on Windows, though (and Mac, iOS, NetWare, Solaris, AmigaOS and more), and is ideal for automating regular downloads in your own custom scripts.

Curl’s basic rules are very simple. Just start by giving it the name of something to download.

curl http://www.example.com
curl ftp://www.test.com/folder/file.txt

By default the contents of whatever you’re downloading is displayed on the screen, but you can redirect this to a file, or use the -o Output option to save it somewhere.

Entering curl –help displays all available commands

curl -o downloadcrew.html http://www.downloadcrew.com

Your resource password might be password-protected, but curl can still access it.

curl http://name:passwd@machine.domain/full/path/to/file

You can download several files at once.

curl -o http://www.test.com/file1.txt http://www.test.com/file2.txt

(As we’re downloading specific files, the -o option will this time save them locally as their online names, file1.txt and file2.txt).

Maybe you only need part of a file? Here’s how to get the first and last 256 bytes of a file.

curl -r 0-255 http://www.domain.com/bigfile.ext
curl -r -256 http://www.domain.com/bigfile.ext

Curl can be smarter that you might expect. You’ll often want to download files only if they’re newer than a local copy, for example, and something like this can help.

curl -z local.html http://www.domain.com/remote.html

Remote.html will be compared to Local.html, and only downloaded if it’s more recent.

This is just the start. Curl can send emails. Upload files. Post forms. Resume file transfers. Set upper or lower transfer speed limits, set a custom referrer or user agent, use cookie authentication and more.

And although it is a command line tool, curl does a good job of keeping you in touch with whatever it’s downloading. A progress bar displays the total download size, the bytes downloaded so far, the average transfer speed, time elapsed, expected completion time and more.

Put it all together and curl has more power in its tiny portable executable (<600KB) than you’ll find in many commercial download managers. If you ever need to script downloads – or you just want to check it out and see what’s possible – then go grab a copy, and take a look.

Your Comments & Opinion

43,098,969
Downloads
Secure & Tested Software
6,454
Reviews
Instant Download 24/7
312,744
Members
10+ Years of Service