I have a file containing records with numbers from 0 to 149. I am writing a bash script that randomly selects 15 of these 150 records and creates another file from them.
I tried using a random number generator:
var=$RANDOM
var=$[ $var % 150 ]
Using var, I selected these 15 entries. But I want all these records to be different. Sometimes the same record gets twice. Is there a way to create a sequence of random numbers in a specific range (in my example, 0-149)?
source
share