Remove white space and duplicate headers

I have a file called "dsout" with empty rows and duplicate headers.

DATE      TIME       TOTAL_GB    USED_GB      %USED                             
--------- -------- ---------- ---------- ----------                             
03/05/013 12:34 PM 3151.24316 2331.56653 73.988785                             
03/05/013 12:34 PM 3151.24316 2331.56763  73.988797  
DATE      TIME       TOTAL_GB    USED_GB      %USED                             
--------- -------- ---------- ---------- ----------                             
03/05/013 12:38 PM 3151.24316 2331.69153 73.9927517                             


DATE      TIME       TOTAL_GB    USED_GB      %USED                             
--------- -------- ---------- ---------- ----------                             
03/05/013 17:00 PM 3151.24316 2331.71716 73.9935651     
............................

I need to have only one header and no empty rows like below.

DATE      TIME       TOTAL_GB    USED_GB      %USED                             
--------- -------- ---------- ---------- ----------                             
03/05/013 12:34 PM 3151.24316 2331.56653 73.988785                             
03/05/013 12:34 PM 3151.24316 2331.56763 73.988797                             
03/05/013 12:38 PM 3151.24316 2331.69153 73.9927517                           
03/05/013 17:00 PM 3151.24316 2331.71716 73.9935651     
............................

Please advise how to do it.

Thank you

awk 'NR<=2{print}NR>2&&/^[0-9]/{print}' dsout
1 Like

That works really well. Appreciate it!

No need for two conditions or print statements:

awk 'NR<3||/^[0-9]/' dsout