elinks -no-numbering -no-references -dump https://matt.might.net/articles/what-cs-majors-should-know/ |
grep -Po '\w+s\b' |
grep or compatible)
elinks retrieves the HTML and converts it to text in its own way. Some alternatives are
w3m -dump or
Then we look for the sequences of one or more word characters in there (word characters being alnums or underscores) followed by a
s provided it's not followed by a word character, and count then with
In essence, the definition of a word there is a sequence of 2 or more alnum or underscore characters and we look for the ones ending in
s (add a
-i option to
grep to also look for those ending in
S). That means the
it's for instance is not counted. If you want wanted to consider single-letter words, you could replace
* above. Or just do
grep -Po 's\b' but then you wouldn't be able to see the list of words when omitting the
| wc -l.
Another approach would be to extract the words first and find the ones ending in
grep -Eo '\w+' | grep -c 's$'
In any case, that's quite a crude definition of word that only works properly for simple English text. When applied to text in other languages, you could run into problems. For instance, it would find a match inside the
abrogowałybyście Polish word (picked at random in a word list) if that
ś was encoded in its decomposed
sU+0301 form (where U+0301 is the combining acute accent) as that
s would be seen as not being followed by a word character.
You may also want to consider what to do about the