3 ms·
You can always do double eval for variables: var=1234 echo `echo {1..$var}`
by bheadmaster 4y ago
You can always do double eval for variables:
var=1234
echo `echo {1..$var}`
- 0xbadcafebee 4y agoYup, which you could also write as eval echo {1..$var} . The second argument's variable is being interpolated as if it's a quoted string, before it gets passed to eval, so eval is actually seeing "{1..1234}" and not doing the interpolation itself (because it wouldn't, because the variable isn't valid in a range). This should prevent the need for a subshell and the second echo call. With an array: var=12 declare -a array=() eval "array=( {01..$var} )" echo "${array[@]}" # 01 02 03 04 05 06 07 08 09 10 11 12