统计文件中单词出现的次数
#get the first file
filename=$1
grep -E -o "\b[[:alpha:]]+\b" $filename | awk ' { count[$0]++ }
END{printf("%-20s%s\n","Word","Count");
for(word in count)
{printf("%-20s%s\n",word,count[word])}
}'
[root@centos6-test06 ~]# cat /root/kevin.txt
the world kevin is the
is world grace the kevin
art the kevin the is kevin
sh count.sh kevin.txt

浙公网安备 33010602011771号