Simple and neat solution


  • 0
    M
    # Read from the file words.txt and output the word frequency list to stdout.
    (tr  -s ' ' '\n' < words.txt) | sort | uniq -c | sort -nr -k1 | awk '{print $2" "$1}'
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.