You have some errors. In addition, you can consider a tool designed for this kind of thing. awk is one of these tools.
awk '/blah blah/ {exit} /Finished/ {count+=1} {next} END{ print count} ' filename
The first line ends when it matches βblah blahβ anywhere on the line.
The second line counts the number of Done matches.
The {next} bit is for reading and not printing each line - this happens in some versions of awk.
The last line, the function END {}, runs when the code completes the file. It displays the value of count.
I chose the awk approach, not trying to fix the logic and syntax errors in the shell script. If you need this kind of help, consider playing almost every block (or line) of code on your own at the command line. I assume you used bash.
Error Examples
-eq to compare strings, use =, example: [ "$var" = "something" ] $(var1) should be either "${var1}" or "$var1" lines 4 and 8
grep returns a whole line, do you test blah blah and expect simple and only blah blah, how is the whole result?
source share