What I'm trying to achieve is the difference between chapter 1 start time and chapter 2 start time and so on subtracting each chapter start time from the next in the array e.g. 00:05:57 - 00:01:03 = 00:04:54
$ cat ChapterStart
00:00:00 00:01:03 00:05:57 00:08:27 00:11:58 00:14:50 00:20:19 00:25:06 00:33:17 00:38:21 00:42:30 00:46:11 00:51:33 01:00:04 01:00:56 01:04:15 01:09:13 01:16:51 01:20:03 01:27:58
This simply doesn't work:
#!/bin/bash
awk 'BEGIN{
{
for(i=1;i<=NF;i++){
m=split($i,t,":")
n=split($(i+1),w,":")
chap = (t[1]*3600) + (t[2]*60) + t[3]
chap_next = (w[1]*3600) + (w[2]*60) + w[3]
duration = (chap_next - chap)
print $duration
}
}
}'ChapterStart
Any suggestions?