Skip to content

Instantly share code, notes, and snippets.

@hollingberry
Last active February 4, 2016 00:14
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 hollingberry/73f639902dc391fdd831 to your computer and use it in GitHub Desktop.
Save hollingberry/73f639902dc391fdd831 to your computer and use it in GitHub Desktop.
#!/bin/sh
# shakespeare - print a list of Shakespeare's plays sorted by word count
curl -s http://shakespeare.mit.edu/index.html |
grep "<a" |
grep -v em |
egrep -o 'href="[a-z_]+' |
sed 's/href="//' |
while read play
do
words=$(curl -s http://shakespeare.mit.edu/$play/full.html | html2text | wc -w)
printf "%17s %5d\n" $play $words
done |
sort -rk 2
hamlet 32063
richardiii 31302
coriolanus 29148
cymbeline 28776
othello 27785
lear 27644
troilus_cressida 27443
henryv 27426
cleopatra 26897
henryviii 25891
winters_tale 25803
romeo_juliet 25715
allswell 24307
richardii 23839
merry_wives 23573
measure 23074
lll 22853
asyoulikeit 22769
much_ado 22477
merchant 22134
taming_shrew 22025
john 21691
titus 21657
twelfth_night 21364
julius_caesar 20789
timon 19574
pericles 19482
macbeth 18165
midsummer 17077
comedy_errors 16132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment