1 2 3 4 5
#!/usr/bin/gawk -f /[0-9]+/ { acc += $1 } !/./ { max[++i] = acc; acc = 0 } END { asort(max); print max[i] + max[i - 1] + max[i - 2] }