使用awk 简单统计 文件第二列中字符串出现的次数
awk '{hash[$2]=hash[$2]+1;}END{for( a in hash){printf("%s,%d\n",a,hash[a]);}}' wrong_id
for a in dict 循环 用法很像是python 的dict 用法,或者shell 中的 for a in *.txt do do samething done
遍历字典(hash,dict)方式
awk:
for (a in hash){
do do samething
}
perl:
foreach my $el (keys %hash){
print "$el\t$hash[$el ]\n";
}
python:
for a in dict:
print (a+"\t"+str(dict[a])+"\n")
print("\t".join(a,str(dict[a]),"\n"))
shell:
for fh in *.txt ;do
do do samething
done
网友评论