Arrays Of Random Numbers
#!/bin/bash
# Create $1 random numbers between zero and $2. e.g. echo $(rand 8 32)
function rand {
rand_2=$(($1*4))
for rand_1 in $(od -vAn -N${rand_2} -tu4 < /dev/urandom); do echo $(($rand_1%$2));done
}
idx=0
declare -a data
for x in $(rand 100 32)
do
data[$idx]=$x
((idx++))
done
for idx in {0..99}
do
echo $idx - ${data[idx]}
done
# Create $1 random numbers between zero and $2. e.g. echo $(rand 8 32)
function rand {
rand_2=$(($1*4))
for rand_1 in $(od -vAn -N${rand_2} -tu4 < /dev/urandom); do echo $(($rand_1%$2));done
}
idx=0
declare -a data
for x in $(rand 100 32)
do
data[$idx]=$x
((idx++))
done
for idx in {0..99}
do
echo $idx - ${data[idx]}
done
Comments
Post a Comment