且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何计算一个单词在目录的所有文件中出现的次数?

更新时间:2021-10-30 07:53:50

grep -roh aaa .|wc -w

递归地grep当前目录中的所有文件和目录搜索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.