24

I have a curl command I would like to execute in a for loop. For example I wanted to loop 1-100 times and when curl command runs it uses iterator variable value in the curl command itself. something like

#!/bin/bash
  for i in {1..10}
 do
    curl -s -k 'GET' -H 'header info' -b 'stuff' 'http://example.com/id=$i'        
 done
 --notice here I want var i to be changing with every curl.

Anything helps Thanks.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
DoodleKana
  • 2,106
  • 4
  • 27
  • 45

1 Answers1

52

Try this:

set -B                  # enable brace expansion
for i in {1..10}; do
  curl -s -k 'GET' -H 'header info' -b 'stuff' 'http://example.com/id='$i
done

See: Difference between single and double quotes in Bash

Community
  • 1
  • 1
Cyrus
  • 84,225
  • 14
  • 89
  • 153