chapter_length=$(( total_length / CHAPTERS )) remainder=0 unset x for vid in ${!VID_LENS[@]}; do adjusted_length=$(( ${VID_LENS[vid]} + remainder )) num_chapters=$(( adjusted_length / chapter_length )) if (( num_chapters > 0)); then chapter_length_array=( $( for ((t=0; t