Count all occurrences of a string in lots of files with grep

前端 未结 15 1577
广开言路
广开言路 2020-11-28 01:07

I have a bunch of log files. I need to find out how many times a string occurs in all files.

grep -c string *

returns

...
f         


        
15条回答
  •  庸人自扰
    2020-11-28 01:43

    You can add -R to search recursively (and avoid to use cat) and -I to ignore binary files.

    grep -RIc string .
    

提交回复
热议问题