//View Tip #42
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"))


View Comments »




Comments 

Add your comment

Comments are currently disabled
Kris Marsh
grep -c pattern
Posted 2008-11-24 23:04:06

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit