This may work:
$ awk '{if ($2~"b") a=NR} END{print a}' your_file
We check every second file for "b" and write the number of lines. It is added, so by the time we finish reading the file, it will be the last.
Test:
$ awk '{if ($2~"b") a=NR} END{print a}' your_file 6
Update based on sudo_O tip :
$ awk '{if ($2=="b") a=NR} END{print a}' your_file
to avoid abc in the second field.
This is also true (in short, I keep one above, because this is the one I thought: D):
$ awk '$2=="b" {a=NR} END{print a}' your_file
source share