I'm running this script:
files=(*)
to_take=$((1*${#files[@]}/10))
x=${#files[@]};
for i in $(seq 1 $to_take);
do
#I've tried initially with the random comment
# r=$((RANDOM%x));
r=$(shuf -i 1-$((x)) -n 1);
echo $r;
# echo ${files[r]};
echo $i;
done;
However, there's an issue. While echo $i
is outputting all i
's in range (hence the loop is working), but echo $r
is just returning one number. The output is like:
r (the random no, eg: 45)
1
2
3
....
....
to_take
Kindly suggest what I'm doing wrong.
P.S.: I tried this:
r=100
for i in $(seq 1 $to_take); do echo $r; done;
The output is just
100
Instead of
100 to_take times.
What is the mistake I'm making?
Edit
A per comments I've used:
for ((i=0;i<to_take;i++))
This code seemingly works, although I shall confimr soon
Look, the issue in hand is to select "to_take" number of .wav files (voice recordings) from the total list of .wav files for training an Automated Speech Recognition System.