{ "data": { "question": { "questionId": "192", "questionFrontendId": "192", "boundTopicId": null, "title": "Word Frequency", "titleSlug": "word-frequency", "content": "
Write a bash script to calculate the frequency of each word in a text file words.txt
.
For simplicity sake, you may assume:
\n\nwords.txt
contains only lowercase characters and space ' '
characters.Example:
\n\nAssume that words.txt
has the following content:
\nthe day is sunny the the\nthe sunny is is\n\n\n
Your script should output the following, sorted by descending frequency:
\n\n\nthe 4\nis 3\nsunny 2\nday 1\n\n\n
Note:
\n\nBash 4.3.30
.