私はプログラムを書いていて、配列に格納されているデータを分割して実行を高速化しようとしています。私はこのようにしようとしています:
data_to_analyze=(1 2 3 4 5 6 7 8 9 10)
#original array size
dataSize=(${#data_to_analyze[@]})
#half of that size
let samSmall="$dataSize/2"
#the other half
let samSmall2=("$dataSize - $samSmall -1")
#the first half
smallArray=("${data_to_analyze[@]:0:$samSmall}")
#the rest
smallArray2=("${data_to_analyze[@]:$samSmall:$samSmall2}")
#an array of names(which correspond to arrays)
combArray=(smallArray smallArray2)
sizeComb=(${#combArray[@]})
#for the length of the new array
for ((i=0; i<= $sizeComb ; i++)); do
#through first set of data and then loop back around for the second arrays data?
for sample_name in ${combArray[i]}; do
command
wait
command
wait
done
私が想像しているのは、最初はデータの最初の配列のみを for ループに渡すことです。最初の配列が完了したら、2 番目の配列セットで再び実行する必要があります。
2 つの質問が残ります。CombArray は本当に 2 つの小さい配列を渡しているのでしょうか? そして、より良い方法はありますか?