Attempting to shorten a bash script that uses curl to fetch multiple API calls takes something like this:
curl --user $USER:$PASS https://api.example.com/foo -o 'foo.json'
curl --user $USER:$PASS https://api.example.com/bar -o 'bar.json'
curl --user $USER:$PASS https://api.example.com/baz -o 'baz.json'
And use it in this form:
curl --user $USER:$PASS https://api.example.com/{foo,bar,baz} -o '#1.json'
The issue is that curl is fetching foo, bar and baz but is not assigning the output to foo.json, bar.json and baz.json. It is literally creating #1.json and piping output to stdout. Has been tried with single, double, and no quotes, all same result. This is being run inside a bash script, although the curl command behaves the same way when entered directly on the command line. Is this an OS X syntax issue?
#1
syntax is supposed to do? Where does that come from? Anyway you're almost certainly better off running three differentcurl
invocations in a loop.#1
syntax is described in thecurl
man page, if you're curious.