leetcode-192 Word Frequency (word frequency statistics)

cat words.txt | tr -s " " "\n"| sort | uniq -c | sort -r | awk '{print $2, $1}'

tr -s "" "\ n": the space is replaced with a line break, that is, in a word file one word per line

sort of word sort

uniq -c count the number of words the same number of words in the word

sort -r positive sequence ordering

awk '{print $ 2, $ 1}' according to the output format, i.e. the number of words in the word finally output to

Guess you like

Origin www.cnblogs.com/leavescy/p/11240497.html