Skip to content

Instantly share code, notes, and snippets.

@luty81
Last active May 13, 2022 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luty81/f6e5603ab7757027f3db9017cd0cd2cd to your computer and use it in GitHub Desktop.
Save luty81/f6e5603ab7757027f3db9017cd0cd2cd to your computer and use it in GitHub Desktop.
AWK Awesome
{
date = $1
hour = substr($2,1,2)
group[date, hour]++
}END{
print "Date" "\t\t" "Hour" "\t" "Total"
print "====" "\t\t" "====" "\t" "======"
for (item in group) print substr(item, 1, 10) "\t" substr(item, 11, 3) "\t", group[item]
}
BEGIN {
print "Metric" "\t\t" "Avg" "\t\t" "Max" "\t\t" "SD +/-";
print "======" "\t\t" "===" "\t\t" "===" "\t\t" "======";
}
{
if (NR > 3 && NR < 6) {
print $2 " " $3 " " $5 "\t\t" $6;
}
else if (NR == 6) {
print "";
print $2;
}
else if (NR > 6) {
print $0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment