标签:
#!/bin/bash if [ $# -ne 1 ] then echo "Usage: $0 filename"; exit -1 fi filename=$1 egrep -o "\b[[:alpha:]]+\b" $filename | awk ‘{ count[$0]++ } END{ printf("%-14s%s\n", "word", "count"); for(ind in count) { printf("%-14s%d\n", ind, count[ind]); } }‘
egrep -o "\b[[:alpha:]]+\b" $filename 可以得到文件中所有的单词 \b为单词边界标记符
标签:
原文地址:http://www.cnblogs.com/guochunyi/p/5809546.html