shell脚本的单词统计问题
发布网友
发布时间:2024-10-09 04:44
我来回答
共1个回答
热心网友
时间:2024-11-29 00:40
#/bin/bash
if [ -f "a.txt" ];then
grep -E -o "\b[[:alpha:]]+\b" a.txt | awk '{ count[$0]++ }; END{for(word in count){print word,count[word]}}'| sort -k 2 > count.txt
else
echo "this is no file a.txt, please check"
exit -1
fi