How to download files using curl

curl is a tool to transfer data from or to a server, using one of the supported protocols: HTTP, HTTPS, FTP, FTPS, SMB… (see the curl Manual for a list of supported protocols). curl also supports HTTP POST, authentication, cookies, metalinks, file downloading and more. curl is an excelent download manager because support progress bar and allows to pause/resume the download from the last downloaded byte.

Download a single file

$ curl -# -C - -O

Download the Alpine ISO to the current DIR.


-#: Progress bar.
-C -: Restart the download from last downloaded byte.
-O: Save the file to the current DIR with the same remote name: alpine-standard-3.8.0-x86_64.

Download several files

Using xargs and curl (wget -I style)

$ xargs -a urls.txt -I{} curl -# -O {}

xargs reads line by line the file urls.txt and passes each line to curl, note the xargs option: -I{} and curl option: -O {}, url.txt looks like this:

Using the -K option

$ curl -# -K urls.txt

urls.txt looks like:

url = "url1"
output = "nom-fich1"

url = "url2"
output = "nom-fich2"

-K option, reading from standard input and using HEREDOC

$ curl -# -K - <<URL
    url = ""
    output = "libsodium-1.0.16.tar.gz"

    url = ""

Further Reading

– man curl

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.