regex to delete multiple blank lines in a file?

can't figure out a way to delete multiple empty lines but keep single empty lines in a file, file is like this
#cat file
1

2

3

4

5
6
-

What I want is
1

2

3

4

5
6
--

any idea?

sed '/^$/d;G' myFile

thanks for the answer, but by doing this, you also ADD a empty line between
5 and 6, which before has no empty line between.

5
6

not
5

6

awk 1 RS= ORS="\n\n" filename

Use nawk or /usr/xpg4/bin/awk on Solaris.

Tjhis is awesome!

Can you explain a little bit what the argument "1" does here?

Sure:

everything <>0 in awk is true (you can use whatever you want: 1,2 ... 42 ...), true means use default action, which is print the current record.

You could use this, if you prefer:

awk -- -42 RS= ORS="\n\n" filename

Thanks again! :b::b::b::smiley: