Created
August 18, 2024 14:05
-
-
Save patrickbucher/37f02602757617076faf2dd3f543f0ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk | |
# sumtime.awk: sums up times | |
# input: lines with time indications of the form hh:mm, e.g. 12:30 or 4:15 | |
# output: the sum of the times, e.g. 16:45 | |
/[0-9]{1,}:[0-9]{1,2}/ { | |
split($0, fields, ":") | |
hours += fields[1] | |
minutes += fields[2] | |
} | |
END { | |
hours += minutes / 60 | |
minutes = minutes % 60 | |
printf("%d:%02d", hours, minutes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment