On 23/10/26 at 17:20, [email protected] wrote:
On Fri, Oct 23, 2026 at 05:18:37PM +0300, Anssi Saari wrote:
The Wanderer <[email protected]> writes:

$ echo {1..10}

, the 'for i in {1..10}; do' is exactly equivalent to 'for i in 1 2 3 4
5 6 7 8 9 10 ; do'.

The coolest thing about this brace expansion is that you can even get
the numbers zero padded for a fixed width, like maybe for filenames or
tabular data.

So echo {01..10} outputs 01 02 03 04 05 06 07 08 09 10.

And it does letters:

     echo {a..l}
     => a b c d e f g h i j k l

...and it composes...

     echo xy{1..3}zzy
     => xy1zzy xy2zzy xy3zzy

...in a Cartesian way...

     echo {1..3}{x..z}
     => 1x 1y 1z 2x 2y 2z 3x 3y 3z

     echo {1..3}{x..z}{2..3}
     => 1x2 1x3 1y2 1y3 1z2 1z3 2x2 2x3 2y2 2y3 2z2 2z3 3x2 3x3 3y2 3y3 3z2 3z3

(I get reminiscences of APL)

(OK, OK, I'm stopping now ;-)

Enjoy

Why splitting in multiple lines a sequence doesn't work:

~$ IFS=$'\n' echo {001..136}

I would expect:

001
002
003
...

instead I got the sequence expanded on a single line, have I to use "tr" forcibly?

Kind regards,
--
Franco Martelli

Reply via email to