shell count lines output

C++
$ somecommand | wc -l
Source

Also in C++: