3 ms·
> I think it also works with letters. Indeed it does. According to the man page : "When characters are supplied, the expression expands to each character lexic
by FoeNyx 10y ago
> I think it also works with letters.
Indeed it does. According to the man page :
"When characters are supplied, the expression expands to each character lexicographically between x and y, inclusive, using the default C locale."
$ echo {a..z}
a 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
But it does not seem to work with ranges outside ASCII such as "à..é", "あ..お", or smileys range, even though my locale should be ".UTF-8" compliant.
Also, you can specify an increment value :
$ echo {0..42..7}
0 7 14 21 28 35 42
$ echo {z..a..3}
z w t q n k h e b
- coldpie 10y ago> Indeed it does. According to the man page : "When characters are supplied, the expression expands to each character lexicographically between x and y, inclusive, using the default C locale." I think 'x' and 'y' are probably the worst variable names they could have chosen for this sentence :)
- mturmon 10y agoThanks. And as your last example illustrates, downward ranges are automatically invoked: $ echo {10..1} 10 9 8 7 6 5 4 3 2 1 As are negative endpoints (shown below with some automatic number formatting, which is turned on when either the first or the second endpoint is padded): $ echo {2..-002} 0002 0001 0000 -001 -002 I just noticed that all this is documented behavior -- another illustration of how rococo this shell has become.