How to generate a list with brace expansion in specific order

I know how to easily generate a list this way :

echo {a,b,c,d}_{0..3}

which will give:

a_0 a_1 a_2 a_3 b_0 b_1 b_2 b_3 c_0 c_1 c_2 c_3 d_0 d_1 d_2 d_3

But how to generate the same list, but with the second brace being expended with an higer priority, to obtain this? :

a_0 b_0 c_0 d_0 a_1 b_1 c_1 d_1 a_2 b_2 c_2 d_2 a_3 b_3 c_3 d_3

Any trick like sorting from the end, or from character n is OK, as long as it fits on one line. I am also using zsh, but something working with bash is fine.


That's not implemented, but you could use an ugly hack like

echo $(eval echo \{a,b,c,d\}_{0..3})

to achieve it by actively first evaluating the latter brace and in the second step the first brace.

Keep in mind though that the intermediate step must be small enough to be still parsable by the shell ;-)

Need Your Help

Rest webservices in UML?

web-services rest uml

How do you reprensent Rest webservices in UML ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.