There's "cat -n" which numbers all lines. (-n is not POSIX, but it's available on at least on BSDs and Linux.)
oh, that's just a man page lookup away. use 'nl -ba' which numbers all the lines. default style is '-bt' which numbers only non-empty ones, as you have experienced...
$ printf 'foo\n\:\nbar\n' | cat -n 1 foo 2 \: 3 bar $ printf 'foo\n\:\nbar\n' | nl -ba 1 foo bar
> sed -n 16p filename > newfile
where 16 is the line number.. this is it! That's quite handy.
There's "cat -n" which numbers all lines. (-n is not POSIX, but it's available on at least on BSDs and Linux.)