I did not know it but it was fun to discover: you can use bash to generate random numbers
/dev/random and /dev/urandom generate random strings.
Some examples of the foolish play i found myself engulfed in:
[gil@XXX ~]$ head -1 /dev/random
?????K
[gil@XXX ~]$ echo $RANDOM
2688
[gil@XXX ~]$ echo $RANDOM
1348
[gil@XXX ~]$ echo $RANDOM
17522
[gil@XXX ~]$ echo $((RANDOM%200-100))
4
[gil@XXX ~]$ echo $((RANDOM%200-100))
-2
[gil@XXX ~]$ echo $((RANDOM%200-100))
-86
[gil@XXX ~]$ echo $((RANDOM%200-100))
-65
[gil@XXX ~]$ echo $((RANDOM%200-100))
97
[gil@XXX ~]$ echo $((RANDOM%200))
15
[gil@XXX ~]$ echo $((RANDOM%200))
95
[gil@XXX ~]$ echo $((RANDOM%200))
59
[gil@XXX ~]$ echo $((RANDOM%200))
166
gil@XXX ~]$ od -An -N2 -i /dev/urandom
61417
[gil@XXX ~]$ od -An -N2 -i /dev/urandom
3756
my source for this lovely discovery - Bash Shell Generate Random Numbers.
No comments:
Post a Comment