Since awk (nice) solution has already been set, there are 4 more ways:
All commands have been tested with your sample and a good .po file.
Using sed
sed -ne '/msgstr ""/{N;s/\n$//p}' <poFile | wc -l 2
Explanation: every time I find msgstr "" , I am concatenating the next line, than if I could suppress the new line as the last character of my line s/\n$// , I print them p . For the final count of the number of rows.
Bash only
Without using any binaries other than bash:
total=0 while read line;do if [ "$line" == 'msgstr ""' ] ;then read line [ -z "$line" ] && ((total++)) fi done <poFile echo $total 2
Explanation: every time I found msgstr "" , I read the next line, and not empty, I increment the counter.
Another bash way
mapfile -t line <poFile count=0 for ((i=${#line[@]};i--;));do [ -z "${line[i]}" ] && [ "${line[i-1]}" == 'msgstr ""' ] && ((count++)) done echo $count 2
Explanation: read the entire .po file in a single array than the search array for an empty field where the previous field contains msgstr "" , increment counter than print.
Perl (in command line mode)
perl -ne '$t++if/^$/&&$l=~/msgstr\s""\s*$/;$l=$_;END{printf"%d\n",$t}' <poFile 2
Explained: Each time I found an empty line and the previous line (stored in the $l variable) contained msgstr "" , then I increment the counter.
Dash (not bash!)
count=0 while read line ; do [ "$line" = "" ] && [ "$prev" = 'msgstr ""' ] && true $((count=count+1)) prev="$line" done <poFile echo $count 2
Based on perl example this work for both bash and dash