#!/bin/bash
declare -A wordCount
while IFS=' ' read -r -a words
do
    for word in "${words[@]}"
    do
        #关联数组保存单词和对应个数
        ((wordCount[$word]++))
    done
done < nowcoder.txt
for word in "${!wordCount[@]}"
do 
    #打印单词和个数
    echo "$word ${wordCount[$word]}"
#将输出的内容按照单词词频按升序排列
done | sort -k2n 
exit 0