Linux统计文件中单词出现的次数

原文链接: http://www.cnblogs.com/S--S/p/10224417.html

grep -E "\b[[:alpha:]]+\b"  /etc/fstab  -o | sort | uniq -c

awk '{for(i=1;i<NF;i++){count[$i]++}}END{for(i in count) {print i,count[i]}}' /etc/fstab

-E 使用正则进行匹配

\b : backspace 退格 print 参数 表示每行匹配完了回车

[[:alpha:]] : 代表所有字符

sort 去重

uniq -c 排序 -c 行首加出现的次数

转载于:https://www.cnblogs.com/S--S/p/10224417.html

猜你喜欢

转载自blog.csdn.net/weixin_30797199/article/details/94834500