File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 55<!-- |@home https://github.com/openset/leetcode |-->
66<!-- +----------------------------------------------------------------------+-->
77
8+ [ < Previous] ( https://github.com/openset/leetcode/tree/master/problems/number-of-1-bits " Number of 1 Bits ")
9+
10+ [ Next >] ( https://github.com/openset/leetcode/tree/master/problems/valid-phone-numbers " Valid Phone Numbers ")
11+
812## 192. Word Frequency (Medium)
913
1014<p >Write a bash script to calculate the frequency of each word in a text file <code >words.txt</code >.</p >
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # Read from the file words.txt and output the word frequency list to stdout.
4+
5+ awk ' {for(i=1;i<=NF;i++) a[$i]++} END {for(k in a) print k,a[k]}' words.txt | sort -k2 -nr
Original file line number Diff line number Diff line change 1+ the day is sunny the the
2+ the sunny is is
You can’t perform that action at this time.
0 commit comments