Curl download multiple files with brace syntax

curl

I am trying to download two files by the following syntax:

curl -O http://domain/path/to/{file1,file2}

The problem is that only the first file is actually saved locally, and the second was simply printed to stdout.

I do realized that if I add a -O it works just fine:

curl -OO http://domain/path/to/{file1,file2}

But isn't this impractical if the number of files grows too big? For example,

curl -O http://domain/path/to/file[1,100]

My question is, is there really no way to download multiple individual files at once with curl (without adding a correct number of -O)?

Best Answer

Update: This has been implemented in curl 7.19.0. See @Besworks answer.

According to the man page there is no way to keep the original file name except using multiple O´s. Alternatively you could use your own file names:

curl http://{one,two}.site.com -o "file_#1.txt"

resulting in http://one.site.com being saved to file_one.txt and http://two.site.com being saved to file_two.txt.

or even multiple variables like

curl http://{site,host}.host[1-5].com -o "#1_#2"

resulting in http://site.host1.com being saved to site_1, http://host.host1.com being saved to host_1 and so on.

Related Question