Question: I need to find the 5 most popular words in a random text, with a bash command. I was trying to make different combinations between `cat`, `wc`, `uniq`, `sort` and `tail`, but couldn't get to anything. Either my output would be a single word, or the text itself, or the wordcount of the text... I should be missing smth...

Is it even possible with a one-liner? Should I approach the problem with smth "a level up", like `for-do`?

F.e. as input: [this random text](http://www.lipsum.com/feed/html) (I've got other texts for my data, but they're too large to show here), and output... well, the 5 most used words (I don't know which ones they are currently :D ).

Answer: 
```
$ cat lorem.txt | tr \  '\n' | tr -c -d '[:alpha:]\n' | tr '[:upper:]' '[:lower:]' | sort | uniq -c | sort -nr | head -5
     10 vitae
     10 in
      9 quis
      9 nunc
      9 eget

```

Walk-thru:

* `tr \ '\n'` separate words on separate records
* `tr -c -d '[:alpha:]\n'` remove non-letters
* `tr '[:upper:]' '[:lower:]'` convert to lower case
* `sort | uniq -c |sort -nr` sort, count and print in frequency order
|head -5 exit in five
This script makes `vitae` and `vitae?` equal. Perhaps you also want eveything in lowercase?  

I think that the `awk` solution of @Brown is better, but a solution with your commands would look like

```
sed 's/[^a-zA-Z]/ /g' loremIpsum.txt |
   tr ' ' '\n' | grep . |  sort | uniq -c | sort -rn | head -5

      8 non
      7 vitae
      7 vestibulum
      7 vel
      7 purus

```