Last active
May 11, 2016 15:23
-
-
Save wytten/84a0a13547d697afb0059904cea02558 to your computer and use it in GitHub Desktop.
Count log events per hour using awk, for a log file containing messages prefixed with date and time e.g., '2016-04-18 02:03:07'
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
$awk -F: '/logMessageOfInterest/ {counts[$1] = counts[$1] + 1; } END { for (val in counts) print val, counts[val]; }' LOG.TXT | sort |
If you want to turn that into a script see http://unix.stackexchange.com/questions/120788/pass-shell-variable-as-a-pattern-to-awk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output, showing lack of events in the 7 o'clock hour
2016-04-19 05 832
2016-04-19 06 496
2016-04-19 08 467
2016-04-19 09 471