Q:

Create alphabetic index with letters repeating

I am running Debian 9. In Bash I can echo {a..z} for the alphabet, or echo {a..z}{a..z} to print letter combinations. However, I would like to generate an index with: a b c d etc. then aa bb cc dd etc. then aaa bbb ccc ddd etc. until it is aaaaa bbbbb (until zzzzz). How could this be done with brace expansion or another similar method? Thanks

A:

You could do:
$ printf '%s ' {a..z}; echo
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

$ printf '%s%s ' {a..z}{,}; echo
aa bb cc dd ee ff gg hh ... ss tt uu vv ww xx yy zz 

$ printf '%s%s%s ' {a..z}{,,}
aaa bbb ccc ddd eee ... ttt uuu vvv www xxx yyy zzz

Explained:
A brace expansion will  create one argument per each value delimited by the comma (and the leading string):
$ echo A{d,u,j}
Ad Au Aj

But, if the value is empty, it will just repeat the leading string:
$ echo A{,,}
A A A

If the leading string is itself a brace expansion, all its strings will be repeated:
$ echo {one,two}{,,}
one one one two two two

Then, the printf (and the trailing echo) are used to format the output:
$ printf '%s%s%s ' {one,two}{,,}; echo
oneoneone twotwotwo

With one letter values:
$ printf '%s%s%s ' {a..d}{,,}; echo
aaa bbb ccc ddd

