Skip to main content
6 of 6
deleted 2 characters in body
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

In bash, you could try:

printf "%s\n" {{a..z},{A..Z},{0..9}}{{a..z},{A..Z},{0..9}}{{a..z},{A..Z},{0..9}}{{a..z},{A..Z},{0..9}}{{a..z},{A..Z},{0..9}}

but that would take forever and use-up all your memory. Best would be to use another tool like perl:

perl -le '@c = ("A".."Z","a".."z",0..9);
          for $a (@c){for $b(@c){for $c(@c){for $d(@c){for $e(@c){
            print "$a$b$c$d$e"}}}}}'

Beware that's 6 x 625 bytes, so 5,496,796,992.

You can do that same loop in bash, but bash being the slowest shell in the west, that's going to take hours:

export LC_ALL=C # seems to improve performance by about 10%
shopt -s xpg_echo # 2% gain (against my expectations)
set {a..z} {A..Z} {0..9}
for a do for b do for c do for d do for e do
  echo "$a$b$c$d$e"
done; done; done; done; done

(on my system, that outputs at 700 kiB/s as opposed to 20MiB/s with the perl equivalent).

Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k