bookmarks/top_words.sh

25 lines
603 B
Bash
Raw Normal View History

2018-09-13 18:58:56 +00:00
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
url="${1:-}"
basedir=$(dirname "$0")
if [[ "${url:-}" = "" ]]; then
2018-09-13 19:03:04 +00:00
grep --only-matching --extended-regexp '[a-zA-Z]{3,}' "$basedir/README.md" \
| tr '[:upper:]' '[:lower:]' \
| grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
| sort \
| uniq --count \
| sort -n
2018-09-13 18:58:56 +00:00
else
2018-09-13 19:03:04 +00:00
curl "$url" \
| grep --only-matching --extended-regexp '[a-zA-Z]{3,}' \
| tr '[:upper:]' '[:lower:]' \
| grep --invert-match --word-regexp --fixed-strings --file=stopwords.txt \
| sort \
| uniq --count \
| sort -n
2018-09-13 18:58:56 +00:00
fi