-2

I have two files "DURATION.txt" and "ABCDURATION.txt" which contain ~900 records where DURATION.txt is the total runtime and "ABCDURATION.txt" is a portion of that total. What I need to do is calculate the percentage of total using these two files.

DURATION.txt EXAMPLE:

0h:2m:54s
0h:6m:17s
1h:55m:42s
1h:5m:9s
...

ABCDURATION.txt EXAMPLE

0h:0m:31s
0h:0m:28s
1h:54m:34s
1h:4m:7s
0h:22m:6s
...

That said I was able to make awk work to accomplish this but not from the DATE/TIME stamp only with whole numbers

Example:

awk 'NR==FNR{t+=$1;next}{printf("%d%s\n", $1/t*100, "%")}' ABCDURATION.txt DURATION.txt

This yields a whole number followed by the "%" sign. e.g. 50%

My question is can I do such a calculation using the TIME/DATE stamps or do I have to convert to seconds or something like that?

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.