how many pass in the file ,three question

Hi all
Question 1:
I want to use "awk" or "sed" to know how many "PASS after "FINISH"
i
Question 2:
I want to use "awk" or "sed" to know how many "PASS" after the *last* "FINISH ,it shoud be 2 in this file

Question 3.
I want to use "awk" or "sed" to know how many "PASS between "789" and "12345"

Thanks for your help

See the following commands.

Ans1:

grep -c "PASS" fine_name
 sed -n '/PASS/p' fine_name | wc -l 

Ans2:

cat fine_name | tr "\n" " " | sed -r "s/(.*) (FINISH.*)/\2/g" | tr " " "\n" | grep -c "PASS"

Ans3:

sed -n '/789/,/12345/p' fine_name | grep -c "PASS"

Thanks for the quick answer. for the first one, I want to know how many "PASS" after FINISH, you tell me total num of PASS in the file

See the following code. to count the total number of "PASS" after matching the first occurrence of the "FINISH"

sed -n '/FINISH/,$p' pass | grep -c "PASS"

Using awk,

awk '/PASS/ &&  c++ && 0 END { print c; }' file

awk '/FINISH/ { f=1 } /PASS/ && f++ && 0 END { print f-1; }' file

awk '/789/,/12345/ { if(/PASS/) {c++;} }END { print c }' file

thanks all