3

I have a variable which contains two alphanumeric sequences separated by a hyphen. I need to expand these to the full inclusive range separated by spaces. Here are some examples to illustrate:

0-9     -> 0 1 2 3 4 5 6 7 8 9
a-h     -> a b c d e f g h
B-Z     -> B C D E F G H I J K L M N O P Q R S T U V W X Y Z
95-101  -> 95 96 97 98 99 100 101

These match bash brace expansion format, so I was looking to use this e.g. {0..9}, but I can't find a way to put variables in the expansion. I can get each side of the expansion, and using seq I can expand the numeric ones, but haven't found a way to expand the alphabetic sequences.

Any solution is fine, whether it uses bash brace expansion, manually separates the sides and expands them through another function, or does anything else.

Joe Herbert
  • 442
  • 5
  • 13

0 Answers0