本文介绍了如何计算一个词在目录的所有文件中的出现次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想计算整个目录中的特定字词。这是可能吗?
I’m trying to count a particular word occurrence in a whole directory. Is this possible?
例如,有一个包含100个文件的目录,其中的所有文件都可能有aaa。如何计算该目录下所有文件中的aaa数量?
Say for example there is a directory with 100 files all of whose files may have the word "aaa" in them. How would I count the number of "aaa" in all the files under that directory?
我尝试过:
zegrep "xception" `find . -name '*auth*application*' | wc -l
但它不工作。
推荐答案
grep -roh aaa。 | wc -w
递归递归搜索aaa的当前目录中的所有文件和目录,并仅输出匹配项,而不输出整行。然后,只需使用 wc
来计算有多少字。
Grep recursively all files and directories in the current dir searching for aaa, and output only the matches, not the entire line. Then, just use wc
to count how many words are there.
这篇关于如何计算一个词在目录的所有文件中的出现次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!