Created
May 19, 2017 19:03
-
-
Save butchhoward/308a885aa9f159fc910c8c046d0e249f 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
Given a file that looks like this: | |
``` | |
017-05-03 08:12:39,911:root:INFO:Begin loading | |
2017-05-03 09:02:43,396:root:INFO:End loading | |
2017-05-04 07:57:09,480:root:INFO:Begin loading | |
2017-05-04 08:47:47,099:root:INFO:End loading | |
2017-05-05 08:06:18,223:root:INFO:Begin loading | |
2017-05-05 08:57:09,491:root:INFO:End loading | |
2017-05-06 08:02:11,492:root:INFO:Begin loading | |
2017-05-06 08:53:30,432:root:INFO:End loading | |
2017-05-07 07:22:28,115:root:INFO:Begin loading | |
2017-05-07 08:13:31,620:root:INFO:End loading | |
``` | |
Parse that to generate durations of the begin/end pairs of lines: | |
```bash | |
grep -E '(INFO:Begin loading |INFO:End loading)' filename.log | cut -d : -f1-2 | awk '{a=$0;s=a;getline b;gsub(/[-:]/," ",b); gsub(/[-:]/," ",a);a=a" 00";b=b" 00"; print s, (mktime(b)-mktime(a))}' | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment