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
You can use a simple grep to capture the number of occurrences effectively. I will use the -i option to make sure STRING/StrING/string get captured properly.
Command line that gives the files' name:
grep -oci string * | grep -v :0
Command line that removes the file names and prints 0 if there is a file without occurrences:
grep -ochi string *