Skip to content

Instantly share code, notes, and snippets.

@u1and0
Last active December 30, 2018 13:51
Show Gist options
  • Select an option

  • Save u1and0/8866a3d84d1528d396978dffd5b1c9c2 to your computer and use it in GitHub Desktop.

Select an option

Save u1and0/8866a3d84d1528d396978dffd5b1c9c2 to your computer and use it in GitHub Desktop.
count words and display ranking
#!/bin/sh
# Catch local data as first argument, and ranking of words top
# Usage:
#
# In shell, top 20
# $ cat *.sh | ./words-rank-local.sh 20
#
# In vim commandline, top 5
# :new | r !cat *.sh | ./# 5
tr '[:upper:]' '[:lower:]' |
grep -oE '\w+' |
sort |
uniq -c |
sort -nr |
head -n "$1"
#!/bin/sh
# Fetch remote url ($1), and ranking of words top 10
curl -s $1 |
tr '[:upper:]' '[:lower:]' |
grep -oE '\w+' |
sort |
uniq -c |
sort -nr |
head -n 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment