Hi, rdcwayx
It's not the eval which generates the data; it's brace expansion.
#Non-numeric example
$ echo f{ee,i,o,um}
fee fi fo fum
#Numeric example
$ echo {0,1}{0,1}{0,1}
000 001 010 011 100 101 110 111
Since the original poster's problem requires a fairly long sequence of digits, for brevity I wanted to avoid:
echo {0,1,2,3,4,5,6,7,8,9,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}{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,etc.....
Storing the list in the variable $digits allows me to do that. However, since brace expansion occurs before variable expansion, we need to send the command line through the shell's parser a second time, using eval. Otherwise we just get:
$ digits=0,1
$ echo {$digits}{$digits}{$digits}
{0,1}{0,1}{0,1}
Instead of:
$ eval echo {$digits}{$digits}{$digits}
000 001 010 011 100 101 110 111
Note: Brace expansion does not occur if there is no unquoted comma within the braces, so we do not need to quote {$digits}.
A downside to this approach is that if the list of digits is long enough, or if there are many braced terms to expand, the list of resulting words could exceed the command line length limit. In such a case, your approach is superior as it never needs to execute a long command line. Another way around this limitation would be to write it out explicitly in the for loop:
$ for i in {0,1}{0,1}{0,1}; do echo $i; done
000
001
010
011
100
101
110
111
IMPORTANT: Brace expansion is not a posix-standardized feature, so if that's a concern, my approach is not an option; yours would be the better choice. Also, the order of brace expansion in relation to parameter expansion as described above is BASH specific (which I chose to use for the illustrative examples since it's much more popular than ksh, and because for this particular scenario it's the more complicated case). In pdksh, ksh88, and ksh93, brace expansion occurs after parameter expansion, not before. So, if using a ksh variant, neither the eval nor the echo nor the command substition is necessary (though in this case their presence does not affect the end result); a simple 'for i in {$digits}{$digits}{$digits}' would be sufficient.
Hope that helps. If not, feel free to ask for clarification.
Cheers,
Alister