Skip to content

Instantly share code, notes, and snippets.

@telekosmos
Created January 14, 2020 13:02
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 telekosmos/d26f7cdfd374b57e51ec4c4955acbaba to your computer and use it in GitHub Desktop.
Save telekosmos/d26f7cdfd374b57e51ec4c4955acbaba to your computer and use it in GitHub Desktop.
[shell] Rank word occurences in a text file
iconv -c -t UTF-8 <file> | tr -dC '[:print:]\t\n' | awk '{for(i = 1; i <= NF; i++) {a[$i]++}} END {for(k in a) if(a[k] >= 1) {print k, a[k]}}' | sort -n -k2 --reverse | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment