Deleting the emty rows in a file

I am getting some spaces between the two lines(rows) in file.i want delete that empty rows in the file

example

         1     abc         xyz


	2     def          jkl 	    

like i am having lots of rows in a file i want to delete the spce between the two rows give any script for my requirement

thanks

it will also remove the if any line contains just spaces... you can remove [ ]* from the below line if you don't want that..

sed '/^[ ]*$/d' filename

here is some more,

awk '{ if ( length($0) > 0 ) print $0 }' file
grep -v ^$ file
sed '/^$/d' file
awk 'length > 0' file

Or just...

awk NF file

Very interesting Ygor....

the below one also works, I'm learning lot of good stuff from this site...

nawk length tmp1

Hi Ygor,
Can you please explain the command you gave, how is it actually working

awk NF filename

Thanks,
Gaurav

as i thought the above awk command should bail out and it did
( in ksh -sun box)

rather this worked,

awk '{ if( NF ) print }' samplefile

could you please explain?

On Solaris use nawk.

Awk programs take the form: condition {action} where each condition is evaluated against each input record. A missing action means print the whole record. NF is a built-in variable which holds the number of fields. A condition evaluates to true when non-zero or non-empty.