16 ms·
My apologies for being pedantic, but that's not quite right, to do something similar you'd need sed 's/ \+/\n/' words.txt | tr A-Z a-z | sort | uniq -c And
by epistasis 15y ago
My apologies for being pedantic, but that's not quite right, to do something similar you'd need
sed 's/ \+/\n/' words.txt | tr A-Z a-z | sort | uniq -c
And to get the top five, you'd need another sort:
sed 's/ \+/\n/' words.txt | tr A-Z a-z | sort | uniq -c | sort -gr | head -5
Where the delimiters of interest go where the space is in the sed expression. Of course, I can never remember what strange regex syntax sed uses, so I have spend 5 minutes trying to puzzle through man page.