{ "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.

\r\n\r\n

For simplicity sake, you may assume:

\r\n\r\n\r\n\r\n

Example:

\r\n\r\n

Assume that words.txt has the following content:

\r\n\r\n
\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\n\r\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Medium", "likes": 363, "dislikes": 240, "isLiked": null, "similarQuestions": "[{\"title\": \"Top K Frequent Elements\", \"titleSlug\": \"top-k-frequent-elements\", \"difficulty\": \"Medium\", \"translatedTitle\": null}]", "exampleTestcases": "a", "categoryTitle": "Shell", "contributors": [], "topicTags": [ { "name": "Shell", "slug": "shell", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "Bash", "langSlug": "bash", "code": "# Read from the file words.txt and output the word frequency list to stdout.\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"37K\", \"totalSubmission\": \"144.5K\", \"totalAcceptedRaw\": 36968, \"totalSubmissionRaw\": 144480, \"acRate\": \"25.6%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "a", "metaData": "{\n \"shell\": true,\n \"manual\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": false, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"bash\": [\"Bash\", \"

Bash 4.3.30.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }