rendered paste body#!/bin/bash
GROUP_CHAPTERS=("30 33.993 76.123 0.6 43.234 87.234 130.345" "30 55.22 120.344 300.233 34.25 66.3")
script='
{
count=ind=1
chapters[ind]=$1
for(i=2;i<=NF;i++){
if($i>$count)
chapters[ind]=chapters[ind]" "$i
else
chapters[++ind]=$i
count++
}
for(chapter in chapters)
printf"Chapter%d: %s\n",chapter,chapters[chapter]
}'
for points in "${GROUP_CHAPTERS[@]}"; do
awk "$script" <<< "$points"
done
### output ###
$ sh awk_chapters
Chapter1: 30 33.993 76.123
Chapter2: 0.6 43.234 87.234 130.345
Chapter1: 30 55.22 120.344 300.233
Chapter2: 34.25 66.3