I have a script with a loop of 5 iterations. In each iteration, the script add lines to an output file. The output file looks like this in the second iteration:

```
#First
Total: 10
Sub: 3
Del: 4
Total2:13
#----------#
#Second:
Total: 15
Sub: 7
Del: 8
Total2:25
#----------#

```

What I want: A line between Del and Total2, with the sum of Total + Sub + Del. So, what I have tried is to put this command (see below) after the "Del" line is printed out, and before "Total2" is printed out.

```
awk '!/^#/ {s+=$2} END {print s}' file

```

It works only for the first iteration.
My desired output:

```
#First
Total: 10
Sub: 3
Del: 4
Sum: 17
Total2:13
#----------#
#Second:
Total: 15
Sub: 7
Del: 8
Sum: 30
Total2:25
#----------#

```

So, I want to find a way to sum only the values of the second column of the previos 3 lines.

I hope I'm explaining...
An awk or bash solution could be great.

Thanks in advance.