{ "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:
\r\n\r\nwords.txt
contains only lowercase characters and space ' '
characters.Example:
\r\n\r\nAssume that words.txt
has the following content:
\r\nthe day is sunny the the\r\nthe sunny is is\r\n\r\n\r\n
Your script should output the following, sorted by descending frequency:
\r\n\r\n\r\nthe 4\r\nis 3\r\nsunny 2\r\nday 1\r\n\r\n\r\n
Note:
\r\n\r\nBash 4.3.30
.