好吧,我不确定您要尝试执行的操作是否正确,但是我可以这样进行:
while read filedo cat $file | tr -cs A-Za-z' 'n'| tr A-Z a-z | sort | uniq -c > stat.$filedone < file-list
现在,您有了所有文件的统计信息,现在可以简单地对其进行汇总:
while read filedo cat stat.$filedone < file-list | sort -k2 | awk '{if ($2!=prev) {print s" "prev; s=0;}s+=$1;prev=$2;}END{print s" "prev;}'用法示例:
$ for i in ls bash cp; do man $i > $i.txt ; done$ cat <<EOF > file-list> ls.txt> bash.txt> cp.txt> EOF$ while read file; do> cat $file | tr -cs A-Za-z' 'n'| tr A-Z a-z | sort | uniq -c > stat.$file> done < file-list$ while read file> do> cat stat.$file> done < file-list > | sort -k2 > | awk '{if ($2!=prev) {print s" "prev; s=0;}s+=$1;prev=$2;}END{print s" "prev;}' | sort -rn | head3875 the1671 is1137 to1118 a1072 of793 if744 and533 command514 in507 shell


