What I want to do it use curl with bash variable to retrieve content length from URL with incrementing parameters.
for ((i=2561;i<=2563;i++))
do
(curl -i -s -k -X 'GET' 'http:someurl.asp?q=$i)
done
When I do like this I always get the same content length from HTTP response. Now if I take same curl command and run outside the loop, like this:
curl -i -s -k -X 'GET' 'http:someurl.asp?q=2562
it works perfectly. I tried both for and while loops, also tried reading from file with cat, but it's always the same content length. What am I missing here?
$2562will be blank unless you pass 2562 parameters to your script.$iwon't be expanded. Moreover, if you want the result to contain a$, you have to escape it, ie use"http:someurl.asp?q=\$$i".curlare unnecessary.$2562is interpreted as${2}562bybash.