numbering blanks

hello i'm trying to figure out how to number a blank line. For instance this :
sed '/./=' file | sed '/./N; s/\n/ /'

gives me
1 aaaa
2 bbbbbb

4 cccccc
5 ffkkkfff
6 ffsdfdfs

I would like something like this:
1 aaaaa
2
3 bbbbbb
4
5 cccccc

And so on... What would i have to do?
I appreciate any help. Thanks.

Do you mind using awk?

awk 'BEGIN {x=1;} {print x,$0;x++}' filename

Or...

pr -t -n filename

Blowtorch,
Is incremental really needed ? :slight_smile:

what about this,

awk '{ printf "%d %s\n", NR, $0 }' filename

1 aaaa
2 eeee
3
4 bbbb
5
6 cccc

Good point... was probably in dummy mode when I wrote that.

using sed

sed = myfile | sed 'N;s/\n/\t/'

....numbers all the lines in a file.

Thanks everyone.