I have a text file containing flight times, hours and minutes separated by colon sign, one per line:00:5000:4100:4300:5001:24I am currently using Apple's Numbers application with a simple formula to calculate the total time (result being 4:28 for the example data above). However, I was wondering if there is an easier way to achieve this. A perl script would work all right, but how about using Unix shell commands and/or scripting? I am basically looking for anything short and simple.Yes, I can manage with Numbers, but this would be nice to know and learn :).p.s. Posting perl script to achieve this in case someone else needs it:#! /usr/bin/perlwhile (<>) {  chomp;  ($hours, $minutes) = split (/:/, $_);  $totalhours += $hours;  $totalminutes += $minutes; }while ($totalminutes > 59) {  $totalhours++;  $totalminutes -= 60;}printf (%d:%02d\n, $totalhours, $totalminutes);
How to sum times in a text file using command-line?
scripting;numeric data
As you note, there are many possibilities.  The following versions with awk are roughly equivalent to the perl you included with your question:(with GNU awk):awk -F : '{acch+=$1;accm+=$2;} ENDFILE { \print acch+int(accm/60)  : accm%60; }' [inputfile](with POSIX awk):awk -F : '{acch+=$1;accm+=$2;print acch+int(accm/60) \             : accm%60; }' [inputfile] | tail -1