Delete blank lines, if blank lines are more than one using shell

Hi,
Consider a file named "testfile"
The contents of file are as below

first line added for test

second line added for test


third line added for test

fourth line added for test




fifth line added for test

I need the output as below

first line added for test

second line added for test

third line added for test

fourth line added for test

fifth line added for test

Pls help me to get the desired output.

To be simple : I want to delete blank lines,if blank lines are more than one.

Thanks in advance

Anil.G

 sed '/./,/^$/!d' infile

should work for you...

1 Like

Thank you Mr , Tytalus

Great day ahead
Anil.G

 cat testfile.txt |sed  '/^$/d' | sed s/$/\\n/
1 Like

Hi Palani
Thanks it working .

Its really a good site. I just love this site.

Rgds
Anil.G

cat -s urfile