$ echo $RANDOM
12517
$ echo $RANDOM
18362
$ echo $RANDOM
26219
$ echo $RANDOM
26056
$ echo $RANDOM
30305
$ echo $RANDOM
9606
but if you want to get smaller random number eg. less than 100, you can do this:12517
$ echo $RANDOM
18362
$ echo $RANDOM
26219
$ echo $RANDOM
26056
$ echo $RANDOM
30305
$ echo $RANDOM
9606
$ number=$((RANDOM%100))
$ echo $number
75
20 random numbers less than 100:$ echo $number
75
$ count=1
$ while [ $count -le 20 ] ; do number=$((RANDOM%100)); echo $number; let "count += 1"; done
93
14
19
96
61
86
63
48
45
26
11
0
89
54
11
84
17
10
99
12
random number less than 10:$ while [ $count -le 20 ] ; do number=$((RANDOM%100)); echo $number; let "count += 1"; done
93
14
19
96
61
86
63
48
45
26
11
0
89
54
11
84
17
10
99
12
$ number=$((RANDOM%10))
$ echo $number
4
5 random numbers less than 10:$ echo $number
4
$ count=1
$ while [ $count -le 5 ] ; do number=$((RANDOM%10)); echo $number; let "count += 1"; done
3
4
9
6
7
and so on...
$ while [ $count -le 5 ] ; do number=$((RANDOM%10)); echo $number; let "count += 1"; done
3
4
9
6
7
4 comments:
saya code php tahu, tapi bab linux command line, then solaris command line memang hancus...ajar boleh ehehehe
saya bleh ajaq, hang nih laki ka pompuan, kalo jantan maleh aaaa...
ekkekkekekekek
ttg seseorang is one of the active reader blog akuuuuu aaaaa
budak baik aaa dia...of cos la laki, ko lion manjang nak kan awek ye, report kat bini ko kang
kekekekekeek.....lawak ja la.
kak red, pi masuk blog bini waaa :)
Post a Comment