Skip to content

Instantly share code, notes, and snippets.

@tekknolagi
Last active February 10, 2023 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekknolagi/e435e35e50a9425f0d3ebf8b7318eae4 to your computer and use it in GitHub Desktop.
Save tekknolagi/e435e35e50a9425f0d3ebf8b7318eae4 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Likely originally by Carl Shapiro
sort |
uniq -c |
sort -n |
sed 's/^ *//' |
awk 'BEGIN { OFS="\t"} { sum += $1; print sum, $1, substr($0, 1 + index($0, " ")) }' |
sort -n -r |
awk 'BEGIN { IFS=OFS="\t"; print "cum", "pct", "freq" }$1 > max { max = $1 }{ print int($1/max*100), int($2/max*100), $2, $3 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment