-11

Tip #42   Count total number of occurances of a string in all files in the

#!/bin/ksh

#KSH only.
# Author: simonvc
# Purpose: Count the total number of occurances of a pattern in all files in the cwd.
# Alt: you could also do "$(grep $pattern * | wc -l) but where's the fun in that ;-)


pattern="WHATEVER"

$ echo $(($(grep -hc $pattern *| tr "\n" "+")"0"))