Removing blank lines from comma seperated and space seperated file.

Hi,

I want to remove empty/blank lines from comma seperated and space seperated files

Thanks all for help

sed '/^$/d' filename

Can you provide a sample of your file if thats something else?

cheers,
Devaraj Takhellambam

FileA

ABC,ABC,ABC
,,,
ABC,ABC,ABC
ABC,ABC,ABC
ABC,ABC,ABC
,,,
ABC,ABC,ABC
,,,
FileB
ABC ABC ABC

ABC ABC ABC
ABC ABC ABC

ABC ABC ABC
ABC ABC ABC

Thanks

Can you think of what's common between FileA and FileB in regards to the so-called 'blank lines'?

sed -e '/^$/d' -e '/^,*,/d' fileA fileB

cheers,
Devaraj Takhellambam

sed -e '/^,*,/d' file1

output

its removing the line

which it is not supposed to.
i want only blank comma seperated line to be removed like the below

Appreciate help

nawk -F'[, ]' '{a=$0; gsub(FS, "",a); if (length(a)) print }' myFile

Thanks vgersh99

I tried to understand this.
1) You are making comma or space as field seperator
2 could not understand

gsub(FS, "",a); 

3) if length of $0 is greater than 0 print $0

Can you please explain

gsub(FS, "",a); 

this part.

Thanks in advance!!

'man nawk' yields:

     gsub(ere,repl[,in])
           Behave like sub  (see  below),  except  that  it  will
           replace  all  occurrences  of  the  regular expression
           (like the ed utility global substitute) in  $0  or  in
           the in argument, when specified.

I know gsub.
but i did not understood the logic.

gsub(FS, "",a);

here you are replacing comma or a space with space right ?

Then when i try this

gsub(FS," ",a);[/

It doesnt work.
Help me understand this.

It is replacing the FS with nothing so that you can count the length of the recrd. Lets say you had
,,, and after replacing , with nothing, you will have nothing, so the length of the record will be zero. so it will not print the record.
if you had ,,ab,, , after replacing , with nothing, you still have ab, so the length will be 2. so it will print the record

Thank you devtakh.
It makes a day better when i learn something.