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"
-K option, reading from standard input and using 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
Further Reading
– man curl