3

This is the best page I could find to help with this, I don't see what I want to do on there: http://wiki.bash-hackers.org/syntax/pe. But I think I've seen this done before.

Say I want to run the same query against Bing and Google (let's assume these would work):

curl -S "https://www.google.com?q=stackoverflow"

curl -S "https://www.bing.com?q=stackoverflow"

Could I run them both in one curl? Like curl -S "https://www.${'bing','google'}.com?q=stackoverflow"

I'd swear I've seen this done before. But I clearly have the syntax wrong. As well as the search terms.

2

Curl understand (and expand) braces:

curl -S 'https://www.{bing,google}.com?q=stackoverflow;'

From man curl:

URL
You can specify multiple URLs … by writing part sets within braces as in:

    http://site.{one,two,three}.com

This is different to shell brace expansions, Curl will not expand Nested braces like the following shell code example will:

$ echo {{1..3},{5..7}}
1 2 3 5 6 7
  • Was it the $ that as goofing me up? – jcollum Dec 19 '16 at 20:53
  • curl -S "https://www.{bing,google}.com?q=stackoverflow;" is simpler and works, is it wrong? – jcollum Dec 19 '16 at 20:54
  • You said it must be unquoted but you quoted it. Confusing. – jcollum Dec 19 '16 at 20:56
  • curl -S "https://www.{bing,google}.com?q=stackoverflow;" does expand... I get 2 curls when I run that. – jcollum Dec 19 '16 at 20:58
  • @jcollum Answer re-written. Yes, the $ seem to be the biggest problem you had. – sorontar Dec 19 '16 at 21:28
1

handled by shell as two url parameters:

curl -S https://www.{bing,google}.com\?q=stackoverflow

handled by internal curl syntax in single url param:

curl -S https://www.\{bing,google\}.com\?q=stackoverflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.