by smokey42 · 12y ago · 0 comments
You are given a text in a file. Count all the words in the
text and print out the words with their number of occurences
in descending order.
This can be depressing at times.Print number of words:
wc -w <filename>
Print words with counts in decreasing order: cat <filename> \
| gawk '{for (i=1;i<=NF;i++) print $i}' \
| sort \
| uniq -c \
| sort -rn \
| less
There are optimizations to be made, but that would be my go to solution in the first instance.