srdotlibre avatar

How to download files using curl

srdotlibre

Published: 18 Aug 2020 › Updated: 18 Aug 2020How to download files using curl

How to download files using curl

curl_logo.png


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 http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-standard-3.8.0-x86_64.iso

Download the Alpine ISO to the current DIR.

Options
-#: 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:

https://download.libsodium.org/libsodium/releases/latest.tar.gz
https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz.sig

Using the -K option

$ curl -# -K urls.txt

urls.txt looks like:

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

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

using -K option, standard input and HEREDOC

curl -# -K - <<URL
url = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz"
output = "libsodium-1.0.16.tar.gz"

url = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz.sig"
output="libsodium-1.0.16.tar.gz.sig"
URL


Via LibreByte


Leave How to download files using curl to:

Written by

Read more #curl posts


Best Posts From srdotlibre

We have not curated any of srdotlibre's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From srdotlibre