cat Samplescript
for OUTPUT in $(grep -lR "Sample sv15 Processor" ./*) #List files with matching string
do
grep "Sample sv15 Processor" $OUTPUT | wc -l
done
My approach is to list files with matching strings
Then run a grep search against each file name from the list.
Finally, use wc -l
via pipeline
What am I missing?
CodePudding user response:
As hinted by @root in the comments grep -cR 'stringtomatch' ./*
will do the task.