Skip to content

Instantly share code, notes, and snippets.

@wytten
Last active May 11, 2016 15:23
Show Gist options
  • Save wytten/84a0a13547d697afb0059904cea02558 to your computer and use it in GitHub Desktop.
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'
$awk -F: '/logMessageOfInterest/ {counts[$1] = counts[$1] + 1; } END { for (val in counts) print val, counts[val]; }' LOG.TXT | sort
@wytten
Copy link
Author

wytten commented May 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment