Last active
December 30, 2018 13:51
-
-
Save u1and0/8866a3d84d1528d396978dffd5b1c9c2 to your computer and use it in GitHub Desktop.
count words and display ranking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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