cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Multiple filename do not work with -O

From: Dave Reisner <d_at_falconindy.com>
Date: Mon, 29 Sep 2014 16:41:47 -0400

On Tue, Sep 30, 2014 at 03:41:27AM +0800, Mike Akiba wrote:
> I want to download three files:
>
> one.jpg
> two.jpg
> three.jpg
>
> After I run:
>
> mike@mike-pc:~/www$ curl -# -R -O http://www.example.com/{one,two,three}.jpg
>
> I ONLY get one.jpg on my disk:
>
> mike_at_mike-pc:~/www$ ls
> one.jpg
>
> two.jpg and three.jpg goes to stdout though.

If you quote your URL, this Just Works™.

The difference is who expands the braces -- curl, or your shell. In the
shell case, you're actually running this command:

  curl -# -R -O \
      http://www.example.com/one.jpg \
      http://www.example.com/two.jpg \
      http://www.example.com/three.jpg

This tells curl to write the first URL to "one.jpg", but gives no
instructions to the latter URLs.

Whereas, quoting it:

  curl -# -R -O 'http://www.example.com/{one,two,three}.jpg'

Now curl does the expansion and understands to apply the effect of -O to
all URLs.

d
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-09-29