aboutsummaryrefslogtreecommitdiff
path: root/bin/rndi
blob: f6cd33daec307e29d88957ebb0dea77afb370884 (plain) (blame)
1
2
3
4
5
6
7
8
9
#!/usr/bin/awk -f
# Get a low-quality random number between two integers. Depending on the awk
# implementation, if you don't provide a third argument (a seed), you might get
# very predictable random numbers based on the current epoch second.
BEGIN {
    srand(ARGV[3])
    print int(ARGV[1]+rand()*(ARGV[2]-ARGV[1]+1))
    exit
}