Skip to content

Instantly share code, notes, and snippets.

@valtoni
Created June 6, 2023 11:31
Show Gist options
  • Save valtoni/4aba7709be240d2853e1db67641bd1ac to your computer and use it in GitHub Desktop.
Save valtoni/4aba7709be240d2853e1db67641bd1ac to your computer and use it in GitHub Desktop.
Group By Count Using awk
find . -name 'message-*.csv' -exec wc -l {} \; | awk -F'[[:space:]-]' '
NR == 1 { print; next }
{
id = $3;
qty = $1;
if (qty < 289) {
reads[id] = qty;
}
} END {
for (r in reads) {
qty = reads[r];
printf "%-15s\t%s\n", r, qty | "sort -rnk2";
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment