//View Tip #42
Kris Marsh
Similar Tips
» Check low space

Latest tips by RSS
Click here to subscribe

Follow Shell-Fu on Twitter
Click here to follow

Follow Shell-Fu on identi.ca
Click here to follow
#!/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"))
#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"))
Comments
Add your comment
Comments are currently disabled
#1
grep -c pattern
Posted 2008-11-24 23:04:06