Explanation
Rather than calling out to python to create a pseudorandom number, we can use the builtin functions of bash
to do this more quickly and with less code.
$RANDOM
is the builtin random number function in bash
. It yields an integer up to 5 digits in length, so this method elects to sample just the first digit from each of the six calls made to $RANDOM
. let
lends its arithmetic capabilities to construct the 6-digit result piecewise, so that:
๐ต = ๐โ + 10๐โ + 100๐โ + 1000๐โ + 10000๐โ
+ 100000๐โ
where ๐แตข
are the 6 initial digits taken from the 6 calls to $RANDOM
.