You need to do variable expansion before the assignment -- a perfect job for the
eval Bash built-in (see
man bash-builtins for details). Try
Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))
eval url$i=${offset}
eval echo "\\\$url\\\$i = \$url$i"
done
Note how the $ characters in the echo are encoded.
eval is applied first; the resulting command (for i=1) is
echo "\$url\$i = $url1". The escaping is sometimes pretty hairy, but it's easier if you work backwards: start from the expression you wish to execute, then add escaping, and finally prepend the
eval to the command.
Hope this helps.