shell – How to Use $variable in Shell Brace Expansion

bashbrace-expansionshell

I want to use $var in a shell brace expansion with a range, in bash.
Simply putting {$var1..$var2} doesn't work, so I went "lateral"…

The following works, but it's a bit kludgey.

# remove the split files
echo rm foo.{$ext0..$extN} rm-segments > rm-segments
source rm-segments

Is there a more "normal" way?

Best Answer

You may want to try :

eval rm foo.{$ext0..$extN}

Not sure whether this is the best answer, but it certainly is one.

Related Question