for ((i=0; i<${#IN_FILES[@]}; i++)); do if ((CHAPTERS > 0)); then if [[ ${GROUP[i]} ]]; then while read line; do group_chapt_array=( "${group_chapt_array[@]}" "$(for p in $line; do echo -n $(format_seconds $p),; done)" ) done <<< $( make_group_chapters "${GROUP_CHAPTERS[i]}") fi fi done # each element gets all lines of output rather than one line per element # group_chapt_array[0] is 00:00:33.089,00:01:16.187,00:00:00.834,00:00:43.933,00:01:27.031,00:02:10.130, # rather than: # group_chapt_array[0] : 00:00:33.089,00:01:16.187, # group_chapt_array[1] : 00:00:00.834,00:00:43.933,00:01:27.031,00:02:10.130,