Sorry if the question is very straight forward but am a newbie to shell scripting. I am trying to write something like this :
for i in {1..20}
do
curl \"
As said above, parameters are not expanded inside single quotes, you have to use double quotes. The only point is that since it occurs in a already double-quoted string, you have to escape them with a backslash (\
), like this:
$ foo=bar $ eval "echo \"something \\\"$foo\\\"\"" something "bar"
Note that there are three \
before the innermost "
, as this will be expanded twice (once when evaluating the argument of eval
and once when evaluating the argument of echo
)
Your quoting is not correct. You don't need double quotes around the second $i
because the whole thing is already surrounded in double-quotes.
Change it to the following:
for i in {1..20}
do
curl "something $i ........ -d 'something $i something'"
done
This is because variables inside the single quotes ''
are not being replaced. If you want variable substitution, you need to get rid of the single quotes.
You coul maybe pre-initialize that variable
foo="something $i bla bla bla"
curl "something ... ${foo}something"